12 Replies
Avoid calling physics code in Update, please use FixedUpdate and save the results into a variable.
Like
IsGrounded
etc.ty
But that isn't your issue really. Just a quick optimization / recommendation.
And prefer to cache the components as using GetComponent is expensive.
?
So do like you did with RigidBody2D but with Collider2D.
In the Start method
yes and
ok
but what I must change than
As for your issue. Does it give you any errors?
no
No errors in Unity's console?
1 wait
Assets\script\Player.cs(7,25): warning CS0108: 'Player.rigidbody2D' hides inherited member 'Component.rigidbody2D'. Use the new keyword if hiding was intended.
Rename your variable to something else.
I usually go for
_rigidBody
when it comes to that warning.Debug, ensure Physics.Raycast returns true