Inconsistense (bugged) linea velocity Y in rigidbody2D (HELP ME TO FIX IT PLEASE)

Hello people! I hope you’re doing great! Dave here with an amazing issue! Thi is the point, I am trying to develop my game in unity again, the context:

I created the player gameObject and attached a rigidbody 2D as well and attached a script for jumping move and those stuffes. Well, i need to validate that my player is on the ground but i need rigidbody 2D linear Velocity Y to validate that i am just falling or stoped by physics (gravity basic functionality) well, the grounded bool var works fine if I move my player to the right, but when i move to the left, grounded is false because:

LinearVelocityY is getting a positive random value if linearVelocityX is negative.

Why is this happening if

rb.linearVelocityX = moveDirection.x * horizontalSpeed;

???

rb.linearVelocityY+= gravitySpeed is constantly been reduced in fixedUpdate to ensure that player is falling, but if I read rb.linearVelocityY, this values becomes weird by changing just X coordinate in velocity property!

Do you know why is this happening???

I don’t but you can check the code on this free asset, see how they did it, and maybe find a solution to your issue

Wow has Rigidbody(2D).velocity been deprecated in Unity 6? That’s wild.

Also please remember to specify whether your post is 2d or 3d, because I was looking at the 3d Rigidbody and was wondering why there is no linearVelocityX/Y properties, because they happen to be 2d rigidbody properties.

Usually a grounded check works by using physics queries to check whether a collider is directly below the player, alongside potentially checking a rigidbody’s vertical velocity. I would not be using velocity alone, as even a grounded game object will still have some vertical downwards force.

ah is 2d, ok, i didn’t noticed that