#💻┃code-beginner

1 messages · Page 845 of 1

naive pawn
#

!input

radiant voidBOT
# naive pawn !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

stark drift
#

sorry if this is a wrong channel to ask this, but i need advice
i tried making multiple versions of a character controller for a 2D game that has moving as fast as possible as the main concept and the approach that felt the best was using transform.position += though i saw some people say that a rigid body would be better so i'm wondering if switching to it would really be worth it (despite the issues i had with it like movement on ground vs in air)

rich adder
swift crag
#

If other physics objects should be able to hit the player and move them around (not just block them!), then you want a rigidbody

polar acorn
rich adder
#

(urgent, today)
sounds sus

stark drift
strong wren
#

@red moat This server is not for these sort of posts

solar hill
#

lol

rich adder
#

...especially when it sounds like a scam

solar hill
#

people love to just tell on themselves

umbral hull
#

hey im not rlly sure how beginner this is, but here's my problem:
im making uno (just as a personal project) and im trying to figure out how to assign the card sprites to the card values so that the correct sprites show on the screen. i already have the hands populated with cards i just am unsure how to go about my problem

upbeat pasture
rich adder
#

I would also go with SOs

upbeat pasture
#

With scriptable objects you can create an object with a color, pickup quantity etc

#

They will also allow you to store the card images

umbral hull
#

They will also allow you to store the card images
yeah i saw this when i looked it up, p nice for my problem

#

right now i have my cards stored as a custom Card class

upbeat pasture
upbeat pasture
rich adder
umbral hull
rich adder
umbral hull
#

ah i see

rich adder
umbral hull
#

but yeah ill look into that, seems very useful in general, thanks

untold crypt
#

hey all 👋 just joined
backend/devops guy here, also messing around with automation tools and indie projects
excited to see what everyone’s working on

rich adder
upbeat pasture
#

CameraManager singleton? Or direct inspector reference to Camera?

#

I feel like Im falling into a common pitfall with the singletons

rich adder
#

depends what needs it

#

simple DI goes a long way, not everything needs a singleton / manager

upbeat pasture
#

I have movement and camera logic split for single responsibility, character controller needs access to Camera transform to rotate the player transform to the Cameras current Y.

upbeat pasture
#

I am most likely going to need a hard reference to camera for camera shake etc though, and I assumed the singleton would be better than 100 inspector references maybe.

#

Ive read a LOT of negative press about the singleton pattern though

rich adder
#

its easy to abuse but they are not bad at all and pretty common pattern outside of unity

rich adder
upbeat pasture
#

PlayerMovement also needs reference to the camera, for rotating the character

#

Maybe theres a cutscene system, that will also now need reference to the camera

rich adder
#

the missle should only say " I hit something" then you can use events to fire a camera shake

umbral hull
#

so when would i use instantiate vs Scriptable Objects? or would i use them together? like ik instantiate is for when i want to spawn alot of the smae enemies in a plaformer or something. i used it once when i had to make a drivable tank for class.

rich adder
#

thats only 1 script tho

upbeat pasture
rich adder
#

they live within another object, like an asset.. think audio asset, a sprite asset etc

umbral hull
#

yeah, instantiate was just one of solutions i was looking at so i was just curious about the question in general

rich adder
swift crag
#

you're describing an apples-and-oranges comparison here

#

to "instantiate" is to copy a Unity object

#

ScriptableObjects are, indeed, a kind of Unity object

#

as are GameObjects, Materials, etc.

rich adder
umbral hull
#

oooh bc instantiate creates the object in the hierarchy, but that wouldnt create the visual effect

rich adder
#

create the visual effect ?

#

you got lost somewhere here..

umbral hull
#

oh i didnt see the response and i got confused

#

nav replying to bamma

rich adder
#

oh

upbeat pasture
#

For example, blank card monobehaviour gets the IMG from the scriptable object, and updates its card image property

rich adder
#

if your sprites have predefined color/number already then SOs were mentioned to assign sprite to specific value/color

#

like I shown in SS

grand snow
#

MVC time

#

Card view to show a card, card data/model to hold the data

swift crag
#

notably, this means that the card that your gameplay systems card about may not be a Unity object at all

cosmic dagger
#

I agree, it can be a helpful tool for explaining code or on how to expand it. I was touching on why we steer newbies away from it (until they learn the fundamentals) bcuz sadly, they don't do any of what you mentioned

It is a separate issue, but they lean on the LLM too much as an aide . . .

cosmic dagger
upbeat pasture
#

MVC is so cool

rich adder
#

who doesn't love uno tho

upbeat pasture
#

another really really good starter project I personally suggest is boids

#

boids are so cool

cosmic dagger
#

Oh, I meant YouTube for the C# fundamentals. That's usually the same across the board (give or take a few topics)

Some may have more than oyhers, but you can get a lot of the basics from websites . . .

cosmic dagger
grand snow
#

Sometimes some good old software design is needed

rich adder
#

C# vids in Unity Context..mostly crap
C# vids in general C# context are the decent ones

grand snow
#

Too much game jank suggested here

cosmic dagger
# grand snow MVC time

@upbeat pasture I may have implemented MVC without knowing, but I can't say I've properly/knowingly tried the pattern. Is that the same or similar to MVVM?

grand snow
cosmic dagger
#

I've never done programming outside of Unity, so I figured these patterns are more C# software development or Web Dev stuff (I think ) . . .

upbeat pasture
#

MVC MVP MVVM are pretty much all the same

#

They just all reference eachother differently

#

Like the MVP is basically jus the MVC but it references the model less?? If I remember correctly.

rich adder
#

WPF flashbacks 😵‍💫

upbeat pasture
#

I like the PISS architecture personally

grand snow
#

SOLID would like a word too

swift crag
#

what's the architecture where you just make the game

#

i can't tell if i'm joking or not right now

upbeat pasture
#

When I started studying software arch I followed SOLID 100%, and it was just a headache

swift crag
#

SOLID is a nice platonic ideal

cosmic dagger
#

I usually stick to KISS and SOLID . . .

rich adder
naive pawn
#

can't seem to find what PISS is supposed to be...

upbeat pasture
#

SOLID is a good idea until everything is abstracted and everything is also a subclass of a class

naive pawn
#

to be pedantic though these are principles not architectures

#

DRY's another one

#

though DRY is pretty good to follow

umbral hull
#

what is MVC? I keep thinking marvel vs capcom lol

naive pawn
#

model-view-controller

grand snow
#

I wouldn't do all of solid but it's ideas are good

rich adder
naive pawn
cosmic dagger
#

I feel like there's a multi-player game with these acronyms as teams in the making

Each team solves the problem using their set of rules . . .

naive pawn
#

architecture is, like many things, better described with pasta shapes

#

just like nuclear pasta

umbral hull
#

theres so many ways to shave a cat notlikethis

upbeat pasture
rich adder
#

not entirely accurate

upbeat pasture
#

Its more if you are making apps

rich adder
#
Unity Learn

By implementing common game programming design patterns in your Unity project, you can efficiently build and maintain a clean, organized, and readable codebase. Design patterns not only reduce refactoring and time spent testing, but they also speed up onboarding and development processes, contributing to a solid foundation that can be used to gr...

cosmic dagger
#

KISS vs SOLID vs DRY vs MVC/P/VM

Two groups are principles that utilize a bunch of different architectural approaches while the other two are specific architecture workflows . . .

upbeat pasture
#

Even if they dont really belong there

naive pawn
cosmic dagger
#

Oh, I don't like bloat . . .

naive pawn
#

damn i only remember SRP and Liskov substitution lmao

cosmic dagger
#

Isn't one of them injection or dependency or smth?

naive pawn
#

i don't remember the other 3, i should go check...

swift crag
#

the "Liskov substitution principle" is just the idea that you can freely substitute B for A if B is a kind of A

upbeat pasture
#

Dependancy injection and single responsibility are the only two good ones to follow

#

and liskov

swift crag
#

i.e. you shouldn't have derived types that fail in situations where the parent type does not

#

for example

#

if you have an Enemy class that has a Move method, you can't add a FlyingEnemy class whose Move method throws an exception if the enemy is on the ground

naive pawn
#

isn't it the inverse

#

ah wait i misread

swift crag
#

which means that the user of the object suddenly has extra rules to obey

naive pawn
#

Single responsibility principle - there should never be more than one reason for a class to change. In other words, every class should have only one responsibility.
Open–closed principle - software entities should be open for extension, but closed for modification.
Liskov substitution principle - functions that use pointers or references to base classes must be able to use pointers or references of derived classes without knowing it.
Interface segregation principle - clients should not be forced to depend upon interface methods that they do not use.
Dependency inversion principle - depend upon abstractions, not concretes.
-# from Wikipedia: SOLID

swift crag
#

Game Actually Exists 😉

upbeat pasture
#

I do not vibe with open closed

dull slate
#

Is learning more efficient through hands-on experimentation with small projects and looking things up as needed, or are structured courses like GameDev.tv more important for building a strong foundation?

solar hill
#

i have no clue what gamedev.tv is but if you want to learn youre best off following the official unity learning pathways

radiant voidBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

keen acorn
# dull slate Is learning more efficient through hands-on experimentation with small projects ...

Heavily depends on the person. I had to go around trying out stuff to see what worked with me the best. Personally, I lacked fundamentals to understand programming, and making small projects for game jams made me feel quite lost, even as I was learning. At the end I took this cool online course a few, and although I'm still a beginner, now I feel quite a lot more comfortable with code: https://www.edx.org/learn/computer-science/harvard-university-cs50-s-introduction-to-computer-science

And of course, there's also, art, music, sounds, etc. Same thing applies, find your personal way to learn

midnight jolt
#

Hi, could someone explain to me why this doesn't want to work? What I'm trying to do is rotate the player to wherever their cursor is at

Vector3 screenToWorld = Camera.main.ScreenToWorldPoint(Input.mousePositionDelta);

transform.rotation = new Quaternion(0, screenToWorld.y, 0, 0);```
#

sorry for the snippet, but not sure if code this short is worth posting on pastebin

rich adder
#

quaternions values max out at 1 so they are not values you typically mess with without using the Quaternion functions like Quaternion.Euler

midnight jolt
#

ohh

rich adder
#

the basic gist, get the direction from your start point in world, to your worldPoint
get the direction. Pass that to the transform forward or rotation, something quaternion.lookRotation

#

or if 2D you can use that direction w Atan / Rad2Deg and, .rotation = Quaternin.Euler(0,0,angle)

midnight jolt
#

3D

#

Okay I see

rich adder
#

so yeah Quaternion is not Euler angles

frail hawk
#

if it is for 3d you dont need to convert mouse to screenworldppoint

#

you need the mouse axis

rich adder
#

if they want the position of the cursor the they do

#

depends what they're making

frail hawk
#

we´d need more context

midnight jolt
#

right now i'm just trying to make the character walk and look around. I've got it to walk, now I'm having difficulties with the rotation

rich adder
#

if its like FPV thing then you don't need ScreenToWorld

#

look at the many examples on how other people do the camera

#

In most cases you're not looking at specific point through mouse pos, you're rotating the player/camera itself to look at specific point

midnight jolt
#

I see

#

it's just I really tried to do this alone y'know

#

to learn

#

but thanks

rich adder
#

once you get base knowledge especially all the components these are easier to build than they seem

naive pawn
upbeat hinge
#

i want to make an ability where the player generates multiple spikes coming out of the ground, how can i do that?

rich adder
upbeat hinge
rich adder
upbeat hinge
#

oh wait before that

#

I created a movment script and everything works except for the jump and double jump

#

using UnityEngine;

public class PlayerController : MonoBehaviour
{
[Header("Movement")]
public float moveSpeed = 8f;
public float jumpForce = 16f;
public float dashForce = 18f;
public float coyoteTime = 0.2f;
public int maxJumps = 2;

[Header("Ground Check")]
public Transform groundCheck;
public LayerMask groundLayer;
public float groundCheckRadius = 0.25f;

private Rigidbody2D rb;
private SpriteRenderer sr;

private float moveInput;
private bool isGrounded;
private float coyoteTimeCounter;
private int jumpsRemaining;
private bool isDashing = false;

void Awake()
{
    rb = GetComponent<Rigidbody2D>();
    sr = GetComponent<SpriteRenderer>();
}

void Update()
{
    moveInput = Input.GetAxisRaw("Horizontal");

    // Ground Check
    isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, groundLayer);

    if (isGrounded)
    {
        coyoteTimeCounter = coyoteTime;
        jumpsRemaining = maxJumps;
    }
    else
    {
        coyoteTimeCounter -= Time.deltaTime;
    }

    // Movement
    if (!isDashing)
        rb.linearVelocity = new Vector2(moveInput * moveSpeed, rb.linearVelocity.y);

    // Jump
    if (Input.GetKeyDown(KeyCode.Space) && (coyoteTimeCounter > 0f || jumpsRemaining > 0))
    {
        rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce);
        jumpsRemaining--;
        coyoteTimeCounter = 0f;
    }

    // Dash
    if (Input.GetKeyDown(KeyCode.LeftShift) && !isDashing)
        StartDash();

    // Flip
    if (moveInput != 0 && !isDashing)
        sr.flipX = moveInput < 0;
}

void StartDash()
{
    isDashing = true;
    float dashDirection = sr.flipX ? -1f : 1f;
    rb.linearVelocity = new Vector2(dashDirection * dashForce, 0f);
    Invoke(nameof(EndDash), 0.18f);
}

void EndDash() => isDashing = false;

void OnDrawGizmosSelected()
{
    if (groundCheck != null)
        Gizmos.color = Color.yellow;
        Gizmos.DrawWireSphere(groundCheck.position, groundCheckRadius);
}

}

rich adder
radiant voidBOT
flint tiger
#

Hey guys

still ingot
#

Hey I'm doing something a little out of my comfort zone and trying to make a ledge climb mechanic for my game. I'm trying to make it precise by calculating the distance between the hit point and the height of the actual mesh/ledge. This is my code currently, the player when the ledge detector ray hits a gameObject with the layer Ledge a second ray will spawn from the hit point of the first ray. I was trying to have it go up (Y+) by using transform.up. Instead I have the screen shot shown. I used more visible colors to make it easier to see in the screen shot

**

  • Raycast From LedgeChecker gameObject (Blue)
  • Normal Surface/Hit Point Second RayCast (Red)
    **
    private void OnDrawGizmos()
    {
        //Main Ray Detector
        Gizmos.DrawRay(ledgeCheckerStart.position, orientation.forward * checkDistance);

        //Normal Y Ray along Ledge Surface
        float distance = (val.normal.y - val.point.y);
        Gizmos.DrawRay(val.point, transform.up * distance);
    }

    private void FixedUpdate()
    {
        LedgeDetector();
    }

    private void LedgeDetector()
    {
        //Check for mesh with Ledge layer
        isLedge = Physics.Raycast(ledgeCheckerStart.position, orientation.forward,out RaycastHit hit, checkDistance, whatIsLedge);
        val = hit;

        if (isLedge)
        {
            var obj = hit.collider.gameObject;
            canHang = true;
        }
        else
        {
            canHang = false;
        }

        //Check find the distance between the hit point of first ray to the height of mesh to snap the player to that location
        if (canHang)
        {
            float distance = (transform.position.y - val.point.y);

            if (Physics.Raycast(val.point, transform.up, out RaycastHit surfaceHit, distance))
            {
                Debug.Log("HIT ALONG SURFACE");
            }
            else
            {
                Debug.Log("SPAWNED LINE ALONG SURFACE");
            }
        }
    }
still ingot
#

How can I make a raycast that is shown in the up direction instead of checking everything below?

frosty hound
#

Raycasts point in the direction you give it, they don't "default" to pointing "below".

#

So whatever direction you're applying, point it up. If you want it straight up regardless of rotation, use Vector3.up

still ingot
#

        //Normal Y Ray along Ledge Surface
        float distance = (Vector3.up - val.point).y;
        Gizmos.DrawRay(val.point, Vector3.up * distance);

        //Check find the distance between the hit point of first ray to the height of mesh to snap the player to that location
        if (canHang)
        {
            float distance = (Vector3.up - val.point).y;

            if (Physics.Raycast(val.point, Vector3.up, out RaycastHit surfaceHit, distance))
            {
                Debug.Log("HIT ALONG SURFACE");
            }
            else
            {
                Debug.Log("SPAWNED LINE ALONG SURFACE");
            }
        }
rich adder
#

since Raycast is only Vector3.up if you pullup the Physics Debugger you should see which direction raycast is going

gusty folio
#

im trying to parent the player to a moving platform so that the player can move with it but for some reason the player doesnt move with said platform. is it because rigidbodies arent fully compatible with parenting?

#

or maybe its just how i coded the platforms

rich adder
gusty folio
eager stratus
#

I'm trying to set a rigidbody's linear velocity inside a coroutine what I assumed would be every physics update (in this case theoretically making it so it travels forward indefinitely), but it's not moving what so ever. Why?

{
    //For the time being just set it to continuously push it back
    while (true)
    {
        print("Should be knocking " + name + " back");
        GetComponent<Rigidbody>().linearVelocity = Vector3.forward;
        yield return new WaitForFixedUpdate();
    }
}```
naive pawn
eager stratus
#

This is what the Rigidbody looks like at runtime and none of these values ever change

naive pawn
#

make sure the object isn't excessively big (since in that case moving 1 unit per second would be very small)

#

also make sure you've actually started the coroutine

eager stratus
eager stratus
naive pawn
#

is the debug message printing continuously?

eager stratus
#

If I have it print the linear velocity before the yield return it gives me the right vector, but if I do it after the yield return then the vector resets to Vector3.zero (Very rarely it'll be the right vector, but it's very rare)

eager stratus
naive pawn
#

do you perhaps have anything else setting the linearVelocity?

eager stratus
#

...Wait

#

I think I know what the problem might be now

#

Ok. That fixed it

#

The animator was set to apply root motion

#

Unchecking it allowed the physics engine to actually affect it

echo ruin
#

It fixes itself if I just copy/paste the word IEnumerator for whatever reason.

#

Still somewhat annoying

verbal dome
#

Currently it thinks you are trying to use the generic IEnumerator<T> from System.Collections.Generic

echo ruin
#

That does make a lot of sense

half lily
#

Hello ! I'm very new and I ran into this problem that I can't figure out :

I have an "Bar" in my HealthBar that I try to scale every frame between 0 and 1 with the healthPercent. Unfortunely, it doesnt update at all. The script works because when I input values manually, it displays the right ratio on load, but it doesnt update when unit takes damage. I dont know what I'm doing wrong.

keen dew
#

You're updating the prefab, not the instantiated object

#

It needs to be something like this:

private HealthBar healthBar;
...
healthBar = Instantiate(...)
...
healthBar.SetSize(...)
frail hawk
#

also transform.Find("Bar") doest make any sense there , if you wanted to reference the bar GameObject you could simply use the inspector

half lily
#

Thank you to the both of you! I managed to make it work :)

midnight tree
#

!collab

radiant voidBOT
# midnight tree !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

midnight tree
#

Also, this is not the right channel to write about this.

fading raven
#

Sorry

#

I didn't mean to do this

naive pawn
#

if you have a specific question, feel free to ask it here or in some other appropriate channel, like i mentioned in #💻┃unity-talk

fading raven
naive pawn
#

are you looking for collaborators, or help on a specific issue?

fading raven
#

Just help

naive pawn
fading raven
#

But here it says code-beginner
That's why I thought it would help

naive pawn
#

this is code-beginner

#

if you have a code question, ask it

fading raven
#

Yes, yes, understood.

#

Thank you and sorry

naive pawn
#

this is a code channel, this seems like an #🏃┃animation question if it's about IK

pseudo hull
#

oh sorry

dry pulsar
#

Guys how can I do:

A random objekt spawn only on x = -2 or 0 or 2

#

** My Idea was to make a random number from 1 to 3 ,
1 = -2 , 2 = 0, 3 = -2 ** is that right?

swift crag
#

That will work, yes.

dry pulsar
#

kk but is there any "better" way

swift crag
#

If you want to be able to configure the positions in the inspector, you could pick a random value from an array

dry pulsar
#

So make an array and give every slot like a position?

swift crag
#
public List<float> positions;

then, elsewhere:

positions[Random.Range(0, positions.Count)];
#

this will give you a random value from that array

dry pulsar
#

kk ty

naive pawn
still ingot
#

Does anyone know how to calculate and find the remaining height of a cube from the raycast hit point. Im making a simple ledge grab mechanic?

#

I tried just turning off the gravity when colliding but then that messed up my player controller so I need to actually use raycast haha

dry pulsar
#

@swift crag @naive pawn is this okay too´?

naive pawn
#

would recommend using something like coroutines rather than InvokeRepeating, but yeah sure

blazing horizon
#

okay so, why does this

_rigidbody.AddForce(Vector3.up * 30);

randomly either do nothing or launch my object stupidly far in an instant

#

object in question

swift crag
#

how are you running that code? in Update?

blazing horizon
#

it checks for key press in update

#

oh it seems that rubbing against cubes can also sometimes cause that

#

(I move the thing by setting linearVelocity)

swift crag
#

if you set the velocity, the old velocity will be lost

#

applying a force causes the velocity to change

blazing horizon
#

I keep the Y value during the setting and I also do horizontal movement before jump handling

#

okay, this is all kind of wacky

#

it seems that the object just fails to zero out its y velocity upon touching ground

#

so it stays on ground, but if I teleport it to y 60 it falls back in an instant

naive pawn
#

in that case you'd pass a ForceMode of either Impulse or VelocityChange

naive pawn
blazing horizon
#

not really

#

and I don't suppose a gravity force of 30 is enough to break the engine

swift crag
#

we'll need to see your code

blazing horizon
#
using UnityEngine;
using UnityEngine.InputSystem;

public class Player : MonoBehaviour
{
    public static Player Instance;

    private Rigidbody _rigidbody;
    private InputAction _moveAction;
    private InputAction _jumpAction;

    void Awake()
    {
        if(Instance!=null) Destroy(gameObject);
        Instance = this;
        _rigidbody = GetComponent<Rigidbody>();
        _moveAction = InputSystem.actions.FindAction("Move");
        _jumpAction = InputSystem.actions.FindAction("Jump");
        _rigidbody.maxLinearVelocity = 10;
    }

    void Update()
    {
        ReactToMove();
        HandleJump();
    }

    public void ReactToMove()
    {
        Vector2 m = _moveAction.ReadValue<Vector2>();
        _rigidbody.linearVelocity = Quaternion.AngleAxis(CameraController.Instance.transform.localEulerAngles.y, Vector3.up) 
            * new Vector3(m.x, _rigidbody.linearVelocity.y, m.y) * 10;
    }

    private void HandleJump()
    {
        if(_jumpAction.WasPressedThisFrame())
        {
            _rigidbody.AddForce(Vector3.up * 30, ForceMode.Impulse);
        }
    }
}
#

after adding the velocity limit it would seem that the object maxes out on vertical velocity and doesn't decelerate

cosmic quail
blazing horizon
#

💀

#

lmao, okay, thanks

#

sneaked right past me

rich adder
blazing horizon
#

oh I know, I'm just throwing a quick prototype, all of this is up for cleanup

hard fossil
still ingot
#

Here is a better visual representation of what I am trying to do. I'm trying to get the distance between the hit point and the top of the ledge height?

rich adder
hard fossil
#

YPosition of Object + Half it's Y size is the position of the top. So just subtract the hit point Y from that.

rich adder
#

caveat.. not all pivots start from middle, and scale on gameobject is a scalar so not accurate sizing,
collider will give you decent size values to work with

hard fossil
#

I'm just going off the diagram, he has the pivot at the center, and when I say size, what I should say is distance incase it's scaled as you say.

rich adder
#

mhm
frankly if I were OP and this is a climb type mechanic I would do multiple queries.
1-2 to get get climbable wall, then check if it has at the top enough space for me to fit, so maybe do an overlap from there

#

something like this

still ingot
#

This is the project I made a gif to show what is happening

#

I have 3 raycast and I'm trying to make sphere cast at each point so its easier for others to see the ledge detectors

#

The ray going upward is too long I need to calculate the hit point and the ledge height to make it precise

rich adder
rich adder
#

once you find the "ground" of the thing you want to climb, I would just do what I suggested. Check if the player can fit if he climbs, through the overlap cast

#

this avoids you trying to climb something that may have a low ceiling

still ingot
#

That's why Im also making wire spheres to better keep track of everything

#

The red ray should stop when it goes above the surface of the ledge so that does need to be fixed

rich adder
#

a hack way you can shoot another ray down to find the floor

still ingot
rich adder
#

once the red ray moves up, as soon as it finds the ground(with ray shooting down from its end pos) it could perhaps move up until there is enough clearance for the player to climb

#

but you can also find the floor / part you need by querying the collider top part

languid pagoda
rich adder
#

they're all trying to move to a single point it makes it jank
I use multiple targets around the player, it keeps them from bunching up

#

most times if they are melee players, they try to encircle the player too..
this keeps it from being boring looking one direction for them

languid pagoda
rich adder
#

use verticality if your design allows, zombies that can also climb down / jump down to you or crawl from small floor spaces will add some spice

still ingot
languid pagoda
hard fossil
# still ingot ``` private Vector3 CalculateLedgeHeight(RaycastHit ledgeRay) { ...

You're reversing the subtraction, and not taking into consideration the half height of the ledge object. It should be ledge Y center position + half Y height of ledge object (which will give you the y position of the top of the ledge), then subtract the ray Y position, so you get the distance between the top of the ledge and the ray.

still ingot
# hard fossil You're reversing the subtraction, and not taking into consideration the half hei...
    private float CalculateLedgeHeight(RaycastHit ledgeRay)
    {
        //Represents y distance between raycast hit and top of ledge
        float ledgeHeight = 0f;

        //Calculate the position of the top ledge
        //It should be ledge Y center position + half Y height  of ledge object (which will give you the y position of the top of the ledge)
        float ledgeYDistance = ledgeRay.point.y + (ledgeCollider.bounds.center.y/2) ;

        //Get the difference (distance in between)
        ledgeHeight = (ledgeYDistance - ledgeRay.point.y);

        Debug.DrawRay(ledgeRay.point, Vector3.up * ledgeHeight, Color.red);

        //Create A Raycast to find the top of the surface
        if(!Physics.Raycast(ledgeRay.point, Vector3.up, out RaycastHit hit, ledgeHeight))
        {

        }

        return ledgeHeight;
    }
#

I get the feeling I might be close but there is something I'm missing to make it the right height

still ingot
#

//Get the difference (distance in between) ledgeHeight = (ledgeYDistance - ledgeRay.point.y) - step;

rich adder
# still ingot ``` private float CalculateLedgeHeight(RaycastHit ledgeRay) { //...

can't you do something like this?

   var raycastHit = Physics.Raycast(
            transform.position,
            transform.forward,
             out var rayHitInfo,
            1.2f
        );

        if (!raycastHit) return;
        hitRay = rayHitInfo.point;

        topCollider = rayHitInfo.point;
        topCollider.y = rayHitInfo.collider.bounds.max.y;

        var startTopPos = topCollider + Vector3.up * charHeight;
        var someOffsetFromEdge = 0.12f;
        var frontHitPosIn = -rayHitInfo.normal * someOffsetFromEdge;
        startPos = startTopPos + frontHitPosIn;

        var colRay = new Ray(startPos, Vector3.down);
        var hitCollider = rayHitInfo.collider.Raycast(
            colRay,
            out var colRay_HitInfo,
            3f
            );

        if (!hitCollider) return;

        // the spot where we want to climb probably?
        //colRay_HitInfo.point```
its kinda hack but might work
you can fix magic numbers tho
#

I used something like this in the past, but the requirements weren't too strict, and was dealing with easy primitives

#

@still ingot

#

there is probably a simpler way but my brain today aint havin it lol maybe someone else has a cleaner more mathy way

still ingot
rich adder
#

gizmos r fun

still ingot
#

This works a lot better for checking the height of the ledge from the hit point!

rich adder
#

k.i.s.s. principle at its best lol

still ingot
hard fossil
rich adder
still ingot
hard fossil
still ingot
#

I actually used @nav example added a debug ray from the top ledge corner!

#
    private float CalculateLedgeHeight(RaycastHit ledgeRay)
    {
        //Represents y distance between raycast hit and top of ledge
        float ledgeHeight = 0f;

        //Get the top height of the mesh
        Vector3 topCollider = ledgeRay.point;
        topCollider.y = ledgeRay.collider.bounds.max.y;

        //Top point Y of the mesh
        var startTopPos = topCollider + Vector3.up * ledgeHeight;
        val2 = startTopPos;
        Debug.DrawRay(startTopPos, Vector3.up * -0.1f, Color.red);

        //Disable wiresphere
        if (!isLedge)
            val2 = Vector3.zero;

        //Create a forward Raycast
        if (!Physics.Raycast(startTopPos, Vector3.up, out RaycastHit hit, -0.3f))
        {
            Debug.DrawRay(startTopPos, orientation.forward * 0.1f, Color.red);
        }

        return ledgeHeight;
    }
#

I think the fact that I wasn't really getting the colliders bounds was the reason why it was difficult

hard fossil
#

float ledgeYDistance = ledgeRay.point.y + (ledgeCollider.bounds.center.y/2) ;

    //Get the difference (distance in between)
    ledgeHeight = (ledgeYDistance - ledgeRay.point.y);

If you look at that too, you'll see that you're adding and subtracting ledgeRay.point.y, so that will cancel to 0, so the ledge height will always be (ledgeCollider.bounds.center.y/2)

still ingot
#

I added more on to the function which snaps the player to the hanging location. I tried adding offsets to help keep the player from merging into the ledge:

        ///////HANG ON LEDGE AT LOCATION BELOW///////

        //Create a forward Raycast
        if (!Physics.Raycast(startTopPos, Vector3.up, out RaycastHit hit, -0.3f))
        {
            Debug.DrawRay(startTopPos, orientation.forward * 0.1f, Color.red);
            isHanging = true;
        }
       
        Vector3 hangLocation = new Vector3(startTopPos.x, startTopPos.y + offsetY, startTopPos.z + offsetZ);

        if (isHanging)
        {
            transform.position = hangLocation;
            rb.useGravity = false;
            playerObject.enabled = false;
        }
rapid stump
#

guys, i need some help, for some reason script is not working

#

like... its actually not working, even debugging with Update does absolutely nothing

#

script is monobehavior, everything was added into the object

still ingot
#

Try making a new script and testing that out with debug logs

#

Then if it works port over the code from the original to test again to be sure its not your code as well

rapid stump
#

for some reason that actually worked but now theres another problem

#

why OnMove() is not working?

rich adder
rapid stump
#

how do i check it?

#

this one?

rich adder
#

thats not what I said, thats not a component

rapid stump
#

oh

#

my bad

#

ohhh

#

i think i need to add one first...

rich adder
shy verge
#

@rapid stump

grand snow
rapid stump
shy verge
#

.wanna join my dev team

rich adder
rapid stump
#

i can do other stuff but i have no time

grand snow
#

not the best channel to beg for team members in id say

rapid stump
#

anyways, thanks, thats actually worked! 🥺

radiant voidBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

fickle plume
#

Sorry wrong person

rapid stump
#

its okay

fickle plume
fickle plume
shy verge
#

Mb man

#

I apologize

cosmic sable
#

!code

radiant voidBOT
cosmic sable
naive pawn
#

the while there will keep looping within the same frame

#

since transform.position isn't changing, this will be an infinite loop

#

keep in mind that Update is already a loop that executes once per frame. you may want an if instead of the while, or consider using coroutines

#

also the first condition in the while is covered by the second one

frail hawk
#

the condition is really weird

#

are you looking for something between -2 and -7 maybe?

cosmic sable
#

adding limits at -2 and -7

naive pawn
#

if you want it to be between those values, you would need <= -2

frail hawk
#

i guess you want || then if you want -2 or -7

cosmic sable
#

yeah like it stops at -2 and -7

#

think I got it

#

thanks peeps

bronze igloo
#

Hello, i want to install the webgl module for unity 6000.3.6f1 and then build, why i dont see an option to install here?

cunning estuary
#

hey im not an good coder

#

how do i make this goal spin around the circle but make it stay in the middle of the line? please help me out

keen dew
#

Put the goal's pivot point in the middle of the circle and then rotate normally

cunning estuary
#

ok wiat

#

im a bit new to unity'

keen dew
cunning estuary
#

let me tryt

muted sand
#

this might be a dumb question, but i'd assume that running new some_class() 100x in a single script is a significantly less strain on the computer than having the script class being put on 100 different objects?

keen dew
#

It's unlikely that there's any measurable difference. The choice should be based primarily on other things than performance

keen dew
#

If it does that then either the pivot point is wrong or the code that rotates it is wrong

cunning estuary
#

ok

#

let me try

#

is therre any other wayt

#

is ther any other way to make it spin like how i want it

rich adder
#

they told you how

cunning estuary
#

im so bad at coding

rich adder
#

you don't even need code for this

cunning estuary
#

huh

rich adder
#

its basic parenting in hierarchy

cunning estuary
#

im very new in unitt

keen dew
#

It's done the same way no matter if you're very new or if you have 20 years of experience

rich adder
cunning estuary
#

ok let me try

#

OMG YES

#

TY

#

TYSM

lament raft
#

Bro every time i move my camera in scene my pc is having a stroke

#

And my pc isnt even using like 20% of its gpu or cpu

still ingot
cunning estuary
#

Hello does any1 know how to get these type of ball phsics https://youtube.com/shorts/yvqsN3EiEFE?si=hJQ2Ca2LmSql0e0q

Step into the electrifying world of 2D football simulations, where neon footballs collide in thrilling arcade-style matchups! ⚽✨ Our videos feature captivating football simulations across the biggest leagues like the Premier League, La Liga, and Champions League. 🏆🌍 Witness neon footballs bounce and battle with stunning visuals that co...

▶ Play video
tall socket
#

Can't figure out any other channel to ask this in, but...
Does anybody have or know of a workaround for the 15 diffusion profile limit in Unity 6.3 LTS HDRP?

tall socket
#

What's the workaround?

still ingot
#

Here is the code I added for my ledge climb script. Now the weird thing that's obvious in the clip I shared is the player will be shifted based on the offset that's great, but its not what I want. I want the players forward location to be offset by the ledge its facing. Also is it possible that I need to make the player a child of the ledge?

        Vector3 hangLocation = new Vector3(startTopPos.x + offsetX, startTopPos.y + offsetY, startTopPos.z + offsetZ);

        

        if (isHanging)
        {
            transform.position = hangLocation;
            rb.useGravity = false;
            rb.linearVelocity = Vector3.zero;
            playerObject.enabled = false;
        }
prime cobalt
#

Anyone know why if two people are working on the same project shared over github and both people have active input system set to 'both', one person would be able to use the unity old input system and new input system in tandem but the other person would only be able to use new input system?

naive pawn
prime cobalt
#

Hmm OK I'll look into that

naive pawn
#

try cycling the active input handling, eg set it to something else and set it back to what you want

cosmic sable
#

do u guys just add an extension for camera? geez I was suffering on making my own and turns out there's cinemachine

#

the drag rotation is kinda tricky

sour fulcrum
#

cinemachine use is very standard yes

sour fulcrum
#

theres also Mathf.Min and Mathf.Max

cosmic sable
#

oh thanks

#

how do u even search these, like what keywords

sour fulcrum
#

To some extent you just slowly pick these up but searching something like "unity limiting value between min or max" or etc. would probably lead you here

cosmic sable
#

this is useful

#

thanks again

sour fulcrum
nocturne carbon
#

i ran into a problem yesterday where when i added a network object and network transform to my character controller in unity that when it jumps it will jump forever, like it never detected leaving the ground and was caught in a loop, i have a cloth sim for his jacket - just wondering if it thinks the ground is the cloth colliders for his legs? Just using the third person controller asset

hard fossil
nocturne carbon
nocturne carbon
#

i think i fixed it, i think it had something to do with the way i reordered the prefab and had some hidden duplicate controller or something wierd, thanks anyway

primal rampart
#

guys if i just want the mesh collider to work properly i should always make it convex right.

night raptor
primal rampart
night raptor
#

I guess Unity thought the mesh would usually just reflect the rendered mesh so there wouldn't be a point in visualizing it

primal rampart
night raptor
primal rampart
#

and its on btw , but i can't see mesh colliders, i can see the other normal collideres like box or capsule

primal rampart
cunning burrow
#

hi

#

i have a question what tutorial should i watch on youtube? iam complete beginner in c# scripting

night raptor
cunning burrow
#

yes

primal rampart
#

well you can find some all in one basics video and understand how C sharp works. Tbh that is enough.

cunning burrow
night raptor
primal rampart
primal rampart
night raptor
#

You need to have the view options enabled though for it to be visible

primal rampart
#

it was at the bottom for me .

naive pawn
cunning burrow
#

i just found good tutorial i think

#

can i send link here

naive pawn
#

for what purpose, exactly..?

cunning burrow
#

to show if is it good

night raptor
naive pawn
#

well no-one's stopping you but you aren't necessarily going to get answers about pros or cons

cunning burrow
#

oh ok

#

ill just watch the tut

orchid trout
#

sort of outside of unity but does anyone know why visual studio sometimes just won't find code that clearly exists? Here it is not finding the exact string im staring at UnityChanThink

night raptor
primal rampart
orchid trout
#

this was yesterday so I dont have VS open in front of me now

night raptor
primal rampart
#

thanks a lot gang

night raptor
primal rampart
#

i just had to turn it on thats it lol

night raptor
#

nice, you are welcome

primal rampart
#

eyy wait one more sec

#

in this excercise im trying to do from "learnunity.com" , the top plane and the cylinders get thrown upwards when i start the game. Everything but the bottom plane has rigid body and all of the meshes have a mesh collider. Why is this the case bruh.

night raptor
primal rampart
#

anything specific?

night raptor
# primal rampart

I don't need that, I want to see the scene which shows all the colliders at once

primal rampart
#

how do i do that?

night raptor
primal rampart
#

where is dis?

night raptor
primal rampart
#

cant find it lol

night raptor
#

it's only there when the Physics Debugger window is active

primal rampart
#

hmm k

restive meadow
#

@everyone I need Help, How to use smartphone keyboard to type something in an input field on Unity WebGL Builds ?

still ingot
#

Please I desperately need help I'm not understanding why my code is not working. Here is the code I added for my ledge climb script. Now the weird thing that's obvious in the clip I shared is the player will be shifted based on the offset that's great, but its not what I want. I want the players forward location to be offset by the ledge its facing. Also is it possible that I need to make the player a child of the ledge?

        Vector3 hangLocation = new Vector3(startTopPos.x + offsetX, startTopPos.y + offsetY, startTopPos.z + offsetZ);

        

        if (isHanging)
        {
            transform.position = hangLocation;
            rb.useGravity = false;
            rb.linearVelocity = Vector3.zero;
            playerObject.enabled = false;
        }
rich adder
muted sand
#

if y'all were to create a spawner of enemies (such as minecraft natural spawning), would y'all do so by using prefabs with monobehavior scripts attached to them, or with a monobehavior script running in the background that inserts all the prefabs into a list and does a function for each of them? i was gonna go with the first option as it seems more straightforward, but will it significantly impact performance?

rich adder
cosmic dagger
muted sand
muted sand
cosmic dagger
#

But yes, you can pool them from a list . . .

lean raptor
rich adder
#

whether or not 1 script controls multiple enemies vs each controlling themselves thats more of a design question.

muted sand
cosmic dagger
muted sand
#

okay, i'll do that, and have another script in each of the prefabs to control its behavior, thanks!

silver fern
#

can I assign a prefab to a variable in code?

rich adder
#

Prefabs are nothing special, they are just regular gameobjects

#

in most cases you want use a component directly on it if you have any besides the Transform one.

silver fern
rich adder
silver fern
rich adder
naive pawn
#

you can do anything in code, but that doesn't mean you should

rich adder
#
var thePrefab = //grab this however you like if not inspector, Resource, IO etc..
mySo.SomePrefab = thePrefab```
#

also true. Is there a specific reason you can't just drop the prefab in SO ?

naive pawn
#

for character SOs? i don't think you would want to do this in code

silver fern
ivory bobcat
#

What's the current sample size?

silver fern
#

currently 32, possibly more later

naive pawn
#

you could have a serializeddict as an editor utility for this, probably

ivory bobcat
#

Referencing from the inspector is part of the level/scene design. So by explicitly setting the field, you're certain that those SOs exist and that those fields are populated. Dynamically assigning the fields during runtime will not ensure any element, so do be aware that there is potential for undefined behavior. Populating the inspector using an editor function is perfectly fine as well, if you're wanting automation.

naive pawn
silver fern
silver fern
ivory bobcat
silver fern
#

and if I drag and drop and change things around it'll keep track of everything?

ivory bobcat
#

You would access your function by right clicking on the component and selecting the context menu function you created to execute the function.

silver fern
#

I don't really know what you're talking about now

naive pawn
silver fern
#

ok idk what any of that means so forget about that, I'll just drag and drop if that's how it has to be done in unity

#

how do I add scriptable objects to a list?

rich adder
#

either inspector or code

#

the process doesn't' change, SOs are assets, Prefabs are assets, Sprites are assets etc..

silver fern
#

for example, I have a scriptable object called LiskarmConfig and I'm trying to do something like private List<ScriptableObject> characterConfigs = new List<ScriptableObject> { LiskarmConfig };

#

but it tells me I can't use the class name in the list

glossy tinsel
#

does anybody know what this means

#

and if so anyway to fix it?

silver fern
glossy tinsel
#

ye

rich adder
glossy tinsel
#

but what

rich adder
#

at least not in that assembly

ivory bobcat
silver fern
#

how do I add the object if not like this?

glossy tinsel
#

im tryna learn so i might be a bit stupid i followed a tutorial

#

this is the tutorial

#

its like 7 years old so somthing might be old

solar hill
#

and what does your script look like?

#

or is the screenshot your script?

glossy tinsel
#

the screen shot is what i copied

#

now im tryna understand why it is what it is

solar hill
#

what does the tutorial show

#

do you have a Player class anywhere in your project?

glossy tinsel
#

this is the bottom

rocky ledge
# silver fern how do I add the object if not like this?

you cant pass a class name directly into a collection initializer because the compiler expects an instance of an object, not a type blueprint, fixing the "Class name is not valid at this point" error in Unity, you must either reference an existing instance or instantiate a new one

rich adder
glossy tinsel
#

i dont know :(

silver fern
glossy tinsel
#

im so confuzled

solar hill
#

Player player;

implies you have Player class in your project

glossy tinsel
rocky ledge
solar hill
# glossy tinsel

im noticing a discrepancy between class names from you and the tutorial

glossy tinsel
solar hill
#

so im going to assume you named your "Player" class something else earlier

glossy tinsel
solar hill
#

do you have any other script in the project?

#

maybe one you made earlier?

glossy tinsel
#

no

#

or ima check wait

#

theres one from the packages

#

but if i click the error it sends me to this one

solar hill
#

can you link the tutorial you are watching please....

glossy tinsel
#

alright

rocky ledge
glossy tinsel
silver fern
rocky ledge
#

lol

solar hill
#

this tutorial is obviously a part 2 or 3 of another tutorial

glossy tinsel
#

oh

#

i think my brain ahs been fried

solar hill
#

it says "Episode 19"

#

at the start of the video

glossy tinsel
#

damn

#

iv been fried from the inside

rocky ledge
#

you can drag assets into a serialized field and access the mwithout isntantiating anything

rocky ledge
# rich adder cursed

im sure you experienced unity folks have a ton to teach me im coming from c# and full stack dev lol

silver fern
# rocky ledge wait what is your goal eactly

so for each character I have an SO containing a reference to the prefab to spawn, and this is for a multiplayer game. so the goal is, when someone picks a character, the game takes the list index of the list of SOs, sends it to the server, and the server picks the SO from the list using the index and spawns the prefab referenced within. If multiple people pick the same character, they will need separate instances of it though

mental spade
#

have tried fixing this for way to long, no matter what I do it takes me back to this error, can someone help me

rich adder
rich adder
#

oh wait..

mental spade
rich adder
#

this is a classic unconfigured IDE/Editor issue

naive pawn
#

!ide

radiant voidBOT
rich adder
#

do you have a class named Monobehaviour

mental spade
rich adder
#

its the wrong one, and it should also be underlined red

ivory bobcat
#

MonoBehaviour

rich adder
rocky ledge
#

but youll need a single source of truht for your character database

mental spade
rich adder
#

c# as 98% of languages, is case sensitive

rocky ledge
#

both the server and the client will look at the characterdataabse list because the list order is the same for everyone

hard fossil
solar hill
rich adder
rocky ledge
#

and when your server reciegvse the index, it instsantiates the prefab inside of it. always creating a unique separate instance of that character.

ivory bobcat
# mental spade no?

Your ide isn't configured. Folks are supposed to redirect you to configuring your ide to prevent simple unwanted spelling/syntax mistakes.

glossy tinsel
#

il be back in 2 days with a horrible stupid problem

solar hill
#

to be fair writing sql feels like youre basically screaming the entire time lol

#

half the shit is in all caps

rocky ledge
#

@silver fern does that help

naive pawn
#

-# also shells kinda for some things if you're on a case-insensitive fs, but arguably that's not the language being case-insensitive

rocky ledge
#

bash 🤮

rich adder
rough granite
rocky ledge
#

$100 if you code your unity game in Fortran

#

lol

rocky ledge
#

honest question: have you made games before?

rich adder
rough granite
silver fern
rocky ledge
#

i only ask because you're gettijng into async stuff

#

and wanna make sure we're on the same page

silver fern
#

and also not online

naive pawn
naive pawn
radiant voidBOT
silver fern
rocky ledge
#

@silver fern especially for mp games, this is true

#

you should definiteyl have a "Source" object

#

so essentially it will contain hte data needed that both the client and the server can see

silver fern
#

thats the prefab

rich adder
#

on somewhat related note, check out these new features in VSC I just noticed
(gameobject in the serializefield is shown in editor)

silver fern
#

the characer prefabs contain all the information relating to the characters, but I need a list of them

rocky ledge
#

think of it this way: you have a book titled "Multiplayer Game", in that you have a chapter. the chapter describes only the characters in the book. the rest of the chapters use those characters from that chapter to buil the rest of the story.

silver fern
naive pawn
#

prefabs persist across scenes, their instances might not

#

prefabs are assets just like SOs

silver fern
#

idk I was told to make SOs to do this

naive pawn
#

are the prefabs for each character structured differently? eg they have different child objects/hierarchy setups

mental spade
rocky ledge
naive pawn
#

if not, you could consider making it so that the data is all on the SO, then you would only have 1 prefab that reads the data from the SO and does stuff appropriately

naive pawn
silver fern
rough granite
mental spade
naive pawn
rocky ledge
#

shrug if it has good information

mental spade
naive pawn
#

ok, have you installed .NET from the .NET install tool?

mental spade
rich adder
#

if it doesnt you can always manually download SDK
just reboot pc after

naive pawn
#

sure, if it still "isn't letting you", please elaborate on what the issue is

naive pawn
silver fern
naive pawn
#

ok? that doesn't go against what i suggested though

silver fern
hard fossil
silver fern
hard fossil
#

If you have a list of spawnable prefabs, the player can send input, left arrow, right arrow to the server, and the server can change the index of the selected prefab.

silver fern
#

that is gonna cause too many problems

#

if an input is dropped its an immediate desync situation

naive pawn
mental spade
hard fossil
#

In the long run, the more decisions the client side is making, the more prone to cheating. The server should be the truth, and the clients just predict a little, then correct.

silver fern
naive pawn
#

then the SO isn't really doing much, you can just use the prefab reference instead

naive pawn
outer swallow
#

Anyone looking to join a team?

naive pawn
radiant voidBOT
# naive pawn !job
<:error:1413114584763596884> Command not found

There's no command called job.

naive pawn
#

whoops, wrong server for that command

naive pawn
radiant voidBOT
# naive pawn !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

silver fern
outer swallow
#

Oh ok

mental spade
naive pawn
#

that's what you're trying to do. what's the "error" you're referring to

#

note that configuring your ide is not supposed to fix errors

#

it is to let your ide help you fix them

outer swallow
#

Is there any severs for builders and coders chris

naive pawn
#

the issue right now is that the error/mistake isn't being highlighted within the ide, which is what configuring the ide is supposed to fix

rich adder
hard fossil
outer swallow
rich adder
silver fern
outer swallow
ivory bobcat
outer swallow
mental spade
outer swallow
#

Dms

hard fossil
rich adder
silver fern
rich adder
#

pretty sure if you google these you find them
also GMTK etc.

rich adder
mental spade
naive pawn
rich adder
#

type dotnet --version in command

naive pawn
outer swallow
#

I got in it how should i recruit people?

tawdry helm
#

I want to make a turn based RPG UI system for a 2d game but every tutorial I find uses canvas and I want a system where the UI is part of a character in the game moving through papers attached to them, with one option going to an inventory with a grid system. My questions are how can/should I move through the papers changing their sprites avoiding two being selected at once due to button mashing/lag and how can I make a zoom in/out to an item on the screen (bag that opens to reveal the grid system) avoiding the zoom to get stuck or permanently changing the zoom in the screen.

rich adder
solar hill
outer swallow
solar hill
#

lmao

ivory bobcat
#

Be convincing.. money is a great incentive.

solar hill
#

would you rather work for a. money or b. a promise of money

#

reasonable people choose a. and laugh at anyone who suggests b. atwhatcost

still ingot
#

Hey does anyone know what's wrong with my I got my player to finally enter a hanging state but it seems to face the wrong direction? I coded it to face the normal of the ledge but that seems to not be working?

    private float CalculateLedgeHeight(RaycastHit ledgeRay)
    {
        //Represents y distance between raycast hit and top of ledge
        float ledgeHeight = 0f;

        //Get the top height of the mesh
        Vector3 topCollider = ledgeRay.point;
        topCollider.y = ledgeRay.collider.bounds.max.y;

        //Top point Y of the mesh
        var startTopPos = topCollider + Vector3.up * ledgeHeight;
        val2 = startTopPos;
        Debug.DrawRay(startTopPos, Vector3.up * -0.1f, Color.red);

        //Disable wiresphere
        if (!isLedge)
            val2 = Vector3.zero;

        ///////HANG ON LEDGE AT LOCATION BELOW///////

        //Create a forward Raycast
        if (!Physics.Raycast(startTopPos, Vector3.up, out RaycastHit hit, -0.3f))
        {
            Debug.DrawRay(startTopPos, orientation.forward * 0.1f, Color.red);
            isHanging = true;
        }

        //Stop the gravity and freeze the player speed and cancel jump animation
        if (isHanging)
        {
            rb.linearVelocity = Vector3.zero;
            rb.angularVelocity = Vector3.zero;
            transform.forward = ledgeRay.normal;
            rb.useGravity = false;
            move.jumpButtonPressed = false;
            playerObject.center = new Vector3(0f,0.5f,0f);
            transform.position = new Vector3(transform.position.x, /*transform.position.y - */((ledgeRay.collider.bounds.max.y /2)), transform.position.z);
        }
        else
        {
            playerObject.center = new Vector3(0f, 0f, 0f);
        }

            return ledgeHeight;
    }
mental spade
rich adder
# mental spade

you can try closing VSC go into UnityEditor under Preferences -> External tools and do Regenerate project Files

#

it might not work properly if you have compile errors though so may be why
fix the typo first if that clears compile error , try again checking if underlines error or offer suggestions

naive pawn
ivory bobcat
tawdry helm
#

Like a recommended approach to avoid problems

naive pawn
#

Monobehaviour instead of MonoBehaviour

mental spade
#

no underline

rich adder
#

we know it was... we're saying that part of the "typo"

ivory bobcat
#

Maybe they've got the incorrect deprecated vscode package

naive pawn
#

right so have that as MonoBehaviour, restart vscode/regen project files, see if it compiles and configures itself correctly

#

(eg afterwards, write Monobehaviour and see if the ide reports the error)

mental spade
#

now it does not correct

rich adder
#

what about random errors

#

did yu do the regen project stuff ?

#

wat happens if you ctrl + click the Monobehaviour ? does it take you somewhere

mental spade
rich adder
#

ok so if you didn't somehow accidentally create a Monobehaviour class.. its still not configured proper

rich adder
#

any errors in the Output tab of VSC?

mental spade
frosty hound
#

It's https://docs.unity3d.com/ScriptReference/MonoBehaviour.html

#

Nevermind it's mentioned above, ignore.

silver fern
novel shell
#

using UnityEngine;

public class CameraCollision : MonoBehaviour
{
public Transform target;
public Vector3 offset = new Vector3(0, 2, -5);
public float smoothTime = 0.3f;
public float collisionRadius = 0.5f;
public float minDistance = 2f;
public float maxDistance = 5f;

private Vector3 currentVelocity = Vector3.zero;
private float currentYaw = 0f;
private float currentPitch = 0f;

public float minPitch = -30f;
public float maxPitch = 60f;

void Start()
{
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
}

void LateUpdate()
{
    if (!target) return;

    float mouseX = Input.GetAxis("Mouse X");
    float mouseY = Input.GetAxis("Mouse Y");

    currentYaw += mouseX;
    currentPitch -= mouseY;

    currentPitch = Mathf.Clamp(currentPitch, minPitch, maxPitch);

    Quaternion rotation = Quaternion.Euler(currentPitch, currentYaw, 0);
    Vector3 desiredPosition = target.position + rotation * offset;

    Vector3 direction = desiredPosition - target.position;
    RaycastHit hit;

    if (Physics.Raycast(target.position, direction.normalized, out hit, direction.magnitude))
    {
        float hitDistance = Mathf.Clamp(hit.distance - collisionRadius, minDistance, maxDistance);
        desiredPosition = target.position + direction.normalized * hitDistance;
    }
    else
    {
        float distance = Vector3.Distance(target.position, desiredPosition);
        float clampedDistance = Mathf.Clamp(distance, minDistance, maxDistance);
        desiredPosition = target.position + direction.normalized * clampedDistance;
    }

    transform.position = Vector3.SmoothDamp(transform.position, desiredPosition, ref currentVelocity, smoothTime);
    transform.LookAt(target.position + Vector3.up * 1.5f);
}

}

What am I doing to prevent it from detecting collisions properly?

radiant voidBOT
silver fern
novel shell
#

I'm getting the typical error where it goes through the wall and there's no collision.

rich adder
#

also you should not move with transforms if you expect any accurate collision

novel shell
#

Then the code is wrong.

silver fern
#

for example by checking overlap

rich adder
#

if you're making a "camera collision" you don't need to do any of this

#

Cinemachine already comes with a built in system for obstacle avoidance

novel shell
#

The collision damages the player, but not the buildings and city.

silver fern
#

how do you check if you collide with a building?

novel shell
#

Is Cinemachine just a matter of installing it? I didn't want to use that kind of thing.

#

When I activate that script, the camera starts vibrating and can't be rotated.

rich adder
#

probably script is wrong / fighting controls over its rotations with something else

novel shell
#

So the camera respects the character's collision, but not the buildings'. I'll check if it's the building collision and let you know.

still ingot
#

Is there a way to make the player's rotation face a mesh at all times?

#

Like climbing in the ledged of zelda: botw

#

or rather more like uncharted

rich adder
still ingot
# rich adder lookdir = (target - origin).normalized quaternion.lookrotation (lookdir)

Thanks! Now the player is facing the ledge perfectly and I am moving on to implementing the actual movement along the ledge.

    /// Move the player along the X axis of the normal of the ledge game object. 
    /// The speed is less than walking speed while hanging and climbing
    /// </summary>
    public void MoveOnLedge()
    {
        //Buttons
        bool leftButton = UnityEngine.Input.GetKeyDown("a");
        bool rightButton = UnityEngine.Input.GetKeyDown("d");
        bool upButton = UnityEngine.Input.GetKeyDown("w");
        bool downButton = UnityEngine.Input.GetKeyDown("s");
        bool jumpButton = UnityEngine.Input.GetKeyDown("w");

        if (leftButton)
        {
            //Move Player to the left along ledgeRay.hit.normal X-
        }
        if (rightButton)
        {
            //Move Player to the right along ledgeRay.hit.normal X+
        }

        if (downButton)
        {
            //Turn player in opposite direction Y-
        }
        if (upButton)
        {
            //Move Player to the top of the ledge Y+
        }
    }
frail hawk
#

could be 2 lines of code instead

still ingot
frail hawk
#

yes really

whole lantern
#

Okay, total newbie question (I am a total newbie, I have no experience in coding), but what would be the code that I use here for applying player movement? I've looked at the documentation for the new Input System, and I got this far, but I just can't find the code for applying the movement with the moveValue.

frail hawk
#

if you want to move physics based you could use the rb velocity or addforce

#

these 2 methods are always recommended

honest marten
#

yo i need help with making a 5 player online game for my comp science lesson i can make sprites and all that but im too dumb and lazy to code, if somone has like some basic project that i can steal it would be awesome

#

i can make soundtracks too i guess

rocky ledge
#

@honest marten youre doing cs but refuse to code?

rich adder
rocky ledge
#

i can help but only in the context of helping you learn

honest marten
#

i mean i did make a platform game back in the day but multiplayer is another level man

#

on game maker..

rocky ledge
#

to be honest its not that bad, i assume youre learning about async?

#

asynchronous programming?

rich adder
honest marten
#

nah man im in highschool i just expand cs and math

rocky ledge
#

understood. well as i said i am happy to help but i wont write code for you

honest marten
#

dw

rocky ledge
#

you should learn and understand unity a bit first though no?

honest marten
#

is it possible to learn it in 7 days

rocky ledge
#

if you have an experienced background in something sure

glossy tinsel
#

im back with questions

#

why pixels be weird

rocky ledge
#

i would say going from no knowledge of game dev or programming would make both harder to learn conceptually

rich adder
#

why are you even taking computer science if none of this stuff intrests you to learn or actually do work

honest marten
#

i mean im in high school man

rich adder
#

this isn't even college?

rocky ledge
#

well, i would argue you should take it seriously anyway, if nothing else youll gain a new way of thinknig about problems

rich adder
#

why bother making a multiplayer then lol that seems overkill for some hs project

rocky ledge
#

think thats his assignment @rich adder

honest marten
rocky ledge
#

do you HAVE to use unity?

#

if not, use something in python

#

far easier

rich adder
#

they would assign it if they taught it, they probably did no learning now wants to rush through

rocky ledge
#

quicker

honest marten
#

i can use anything

rocky ledge
#

ok

#

use python

honest marten
#

i could even make a game in roblox but i dont think im that lazy

rocky ledge
#

find some code for geometric shapes, make it squares and lines, make it a 4 player pong game, use libraries, done

#

all of that should be achievable i think

#

but again, you gotta like...at lesat have an idea of what youre doing

honest marten
#

what about something like claude code

rocky ledge
#

maybe, i dont know. you gotta make the call

honest marten
#

i used it once but it didnt make sense to me

rich adder
#

anyway this isn't the place for that

solar hill
honest marten
#

i mean may

#

but im not really a coder man

#

im a composer

whole lantern
rich adder
# whole lantern Sorry, I'm really new to this. I'm not quite understanding what you mean by "app...

it appears more complicated then it is because theres a lot of lines.
if you isolate the relevant parts to input and movement.
Vector2 input = moveAction.action.ReadValue<Vector2>();
Vector3 move = new Vector3(input.x, 0, input.y); // its applying vertical input (y) to the Z so it can move forward/back in 3d space, the x is side movement. in 3D

// Move
Vector3 finalMove = move * playerSpeed + Vector3.up * playerVelocity.y;
controller.Move(finalMove * Time.deltaTime);```
whole lantern
rich adder
glossy tinsel
#

im back

rich adder
#

You don't have to announce it lol

glossy tinsel
#

i couldent figure out why hes weird

rich adder
#

its clear once you post an actual question

glossy tinsel
#

like santa

#

screaming when he comes into your house

solar hill
#

hilarious.

rich adder
glossy tinsel
#

oh

solar hill
#

this is a coding channel

glossy tinsel
#

thank you

#

i dont know why but my adrenaline is spiking while doing this

still ingot
# rich adder it appears more complicated then it is because theres a lot of lines. if you iso...

Hey I implemented a MoveOnLedge function and my player moves along the ledge now! Here is what I have if anyone has an idea on how to turn the character when they reach a corner

    public Vector3 MoveDirection()
    {
        return Vector3.zero;
    }

    /// <summary>
    /// Move the player along the X axis of the normal of the ledge game object. 
    /// The speed is less than walking speed while hanging and climbing
    /// </summary>
    public void MoveOnLedge()
    {
        float horizontalInput = Input.GetAxisRaw("Horizontal");
        float verticalInput = Input.GetAxisRaw("Vertical");
        // calculate movement direction
        moveDirection = orientation.right * horizontalInput;

        rb.AddForce(moveDirection * 0.1f, ForceMode.Force);

        if (Mathf.Abs(moveDirection.y) == 0f)
        {
            moveDirection.y = verticalInput;
        }
        else
        {
            moveDirection.y = verticalInput;
        }

        if ((Mathf.Abs(horizontalInput) == 0f))
        {
            rb.linearVelocity = Vector3.zero;
        }

    }
solar hill
still ingot
rich adder
#

jfc good thing my audio was muted

solar hill
#

i just blasted that full volume on my speakers 😔

still ingot
#

I can make one with no audio

solar hill
#

no its fine lol it just caught me off guard

still ingot
#

but I would like to share this code with others when im done

#

im trying to make an easy way to ledge climb

rich adder
hybrid gust
#

is there a way I can get the frequency and damping behavior from a SpringJonit2D on a SliderJoint2D?

#

Or conversely can I get the behaviour provided by the angle parameter from a SliderJoint2d for a SpringJoint2d?

#

nvm idk why i thought i couldn't use both components on the same gameobject that had bad results

clever prairie
#

guys where can I find a tutorial or guidebook for all of the common physics and rigidbody scripts? I made a few scripts using AI, but, I wanna fix some details on them and, since Gemini cant code them correctly, I'll have to learn how to code them myself.

slender nymph
#

!learn

radiant voidBOT
vivid quarry
#

Heyoo, I was wondering what the best way is to determine if an object is being occluded by a wall? Raycasting to AABB corners works fine for something like boxes, but when trying to determine if a sphere is being occluded, raycasting to the AABB corners doesn't work well. I tried using sphere casting but that can lead to false positives as it can get caught on the edges of the wall. Is there another way that is most accurate that I could go for?

night raptor
# vivid quarry Heyoo, I was wondering what the best way is to determine if an object is being o...

Could you explain the context around this issue? What you need the occlusion information for? One common solution is to fire a larger number of rays in some kind of grid pattern. There is no fast and perfectly reliable (never false positives or negatives) occlusion algorithm. Well technically you could render the image to an object ID buffer and calculate the occlusion from there in a compute shader for example but the problem with that is that even though it could probably be implemented pretty fast, there is no fast readback from the GPU so there will be couple frames of delay to get the information back to C# side

vivid quarry
vivid quarry
vivid quarry
teal viper
rich adder
vivid quarry
# teal viper Do you really need near perfect detection though? Is one ray at the center not e...

Well, I want to eliminate the possibility of a player being able to see the enemy move as that'd ruin immersion. It's a horror game so preferably I would want to reduce the chances of them seeing the enemy move.

However I suppose I could do some prediction and flicker the lights or something like that if not possible. That would theoretically prevent the player from seeing the movement 🤔

solar hill
#

im confused, is the player ever supposed to see the enemy then?

#

i feel like this is an xy problem more than anything

night raptor
#

I think the point is the player is never meant to see the enemy move

vivid quarry
solar hill
#

then dealing with perfect ray detection no?

teal viper
solar hill
#

Yeah raycasts are as cheap as they come

vivid quarry
# solar hill then dealing with perfect ray detection no?

well, I want the enemy to be able to move when the player is not looking at them, which would include being behind a wall. Though they'd be visible if parts of their body were visible around the edges of the wall. I'm not sure how else I would be able to accomplish that without perfect ray detection

solar hill
#

which perspective is this game in?

#

first?

vivid quarry
#

First person

#

yeah

solar hill
#

couldnt you just use something like "Renderer.isVisible"

#

basically the enemy listens to the player, to see if it can move at all

teal viper
#

That's the frustum culling part.

#

It would be true behind walls

solar hill
#

yeah but in a combination with a raycast you dont need much more no?

vivid quarry
#

hmm I'll need to test that

solar hill
#

i might be overthinking it, and it could be overkill, but if you want to ensure that even if a smidge of the enemy is peaking around the corner, you could get the enemy's 3d boundaries as 2d screen coords and then basically hit it with a lidar scan of raycasts lol

teal viper
#

You can also provide simpler colliders, like boxes for your enemies to do less raycasts. It might stop moving a little earlier, but small margin shouldn't be a problem, right?

night raptor
#

I think that would be very reasonable approach. One probelm that I'm wondering just now is that if you have shadows enabled, you might see that shadow moving even though the object itself is not in view, would that be an issue? isVisible I think returns true also when it is visible to some of the shadowmaps but if you need to take that into account in your raycasting logic, it would quickly get really complicated

vivid quarry
solar hill
#

the shadow thing doesnt seem so bad

#

honestly from a design perspective more than anything

#

could be a cool problem turned feature

vivid quarry
#

The enemies don't walk. They just teleport so it would look kinda funky haha, but maybe it'll look cool. I did it this way as it is a multiplayer game, and it would be possible I believe, due to latency, that you could see the enemy moving if it was with just default walking.

solar hill
#

oh i got some bad news

#

if its a multiplayer game, theres almost 0% chance you can guarantee the enemy wont ever be seen moving

#

unless its movement is entirely client side

night raptor
#

I mean you would get closer by increasing the margins (like the size of their colliders) enough

teal viper
#

Multiplayer kinda makes it 10x more difficult, as you'll either need to simulate every player camera on the server, or deal with latency uncertainty.

solar hill
#

latency is gonna be the biggest issue

solar hill
#

i cant think of a single multiplayer game with this kind of mechanic thats done it proper justice lol

#

even scp secret lab try as they might cant get scp 173 to look good

#

its just a flying peanut half the time lol

vivid quarry
#

then no matter what I'll have to probably make it so, if a enemy is somehow moving into a player's perspective and is not frozen, perhaps I'll just flicker the lights on the client for however long the duration must be

vivid quarry
solar hill
#

smoke and mirrors can get you pretty far

#

your light flickering idea is already there

still ingot
#

I made an attempt at trying to get the player to rotate using a spherecast but it doesn't seem to work?
Code:

    private void CheckCorners()
    {
        ///////Rotate around corners BELOW///////

        //Create a forward Raycast
        if (isHanging)
        {
            Debug.DrawRay(LeftChecker.position, move.orientation.forward * 1f, Color.red);
            Debug.DrawRay(RightChecker.position, move.orientation.forward * 1f, Color.red);

            if (!Physics.Raycast(RightChecker.position, move.orientation.forward, out RaycastHit lineHit, 1f))
            {
                if (Physics.SphereCast(RightCornerCheck.position, .1f, move.orientation.forward, out RaycastHit sphereHit, 1.5f, whatIsLedge))
                {
                    Vector3.Slerp(transform.forward, sphereHit.point, 1f);
                }
            }
        }
    }
#

I have a raycast that checks for when there is no ledge on the side. I then create a sphereCast that is supposed to hit the side of the wall around the corner. When it hits the player is supposed to rotate around to the hit point but it isn't functioning properly like how I intended. I might have to create a ray from the side of the wall in stead of a sphere.

teal viper
#

And the params are all over the place as well. A is a direction, b is a position. T is 1, so the result would always be the sphere hit point(position).

#

P. S. You should use debug rays and other gizmos more actively for visual validation. Make sure to use different colors too to make it clear what's what.

waxen jasper
#

Okay i have a design question in my first ever Unity game. My game has multiple rounds. In each round, the player drops all of the balls they have down a pegboard. In between rounds they can add balls to their collection.

My question is, how do i store all of these balls in a list that persists between rounds. I’m confused because the actual game objects won’t persist, but i still need to know what balls are in the users collection
Btw these different balls behave differently, it’s not just a different sprite

rich adder
# waxen jasper Okay i have a design question in my first ever Unity game. My game has multiple ...
Unity Learn

In this tutorial, you’ll learn how to use data persistence to preserve information across different scenes by taking a color that the user selects in the Menu scene and applying it to the transporter units in the Main scene. By the end of this tutorial, you will be able to:

Ensure data is preserved throughout an application session by using t...

waxen jasper
#

I guess I’m more asking how to store the balls

#

Instead of a list of game objects

#

A list of what

upbeat nebula
#

can't you just write in files? or store the data in a singleton?

upbeat nebula
rich adder
#

List is generic you can put whatever you want as long as the type is the same

upbeat nebula
#

Anyone learned the HSM? (hierarchial state machine)? if you did, what resource you checked to learn it cuz rn im confused

waxen jasper
#

But can i have instances of the type my balls are, without having game objects to go with them

rich adder
waxen jasper
#

Let me reword bc i think I’m confusing myself and you guys on what I’m asking

#

During the round the user will have a bunch of balls to drop, which are game objects that are destroyed when they reach the bottom. But even when the game object is destroyed i still need a list keeping track of all the balls they have currently bc they drop them again next round

#

I was under the impression that one instance of my hall class is made per game object

rich adder
#

yes which is why I said normally you store the Data itself not the instances of gameobjects

waxen jasper
#

Okay so i need to store data that describes the ball

rich adder
#

yup

waxen jasper
#

And the prefab would be included in that data?

rich adder
#

the prefab is a blank slate until you feed it the data

#

normally a SO is used

waxen jasper
#

Like let’s say I have prefabs for different kinds of balls

rich adder
#

POCO works too

waxen jasper
#

Then i store a list of balldata

#

Where the prefab is included

rich adder
#

If they have completely different prefabs then you could store the preab too ig

waxen jasper
#

What’s SO and POCO

rich adder
#

ScriptableObject
and Plain Old Class / Clr object

waxen jasper
#

Well i can make a scriptable object i was planning to do that after your recommendation

#

But the SO needs to store the prefab right?

rough granite
rich adder
rich adder
rough granite
waxen jasper
#

Okay you may have technically answered this in something you said, but I’m a bit lost on one thing. Let’s say i have a scriptable object, which has data to represent a type of ball. If I’m not storing a prefab, how can i actually make a game object from that SO

rich adder
rich adder
#

what kinda data do they hold

waxen jasper
#

Wait what kind of data does what hold

rich adder
#

balls ?

waxen jasper
#

Well that’s the thing i don’t know what it should be holding

#

I’m thinking it needs to hold the type of ball it is