C
C#5mo ago
Rosor

why I can not jump

c# unity 2d
No description
12 Replies
Buddy
Buddy5mo ago
Avoid calling physics code in Update, please use FixedUpdate and save the results into a variable. Like IsGrounded etc.
Rosor
RosorOP5mo ago
ty
Buddy
Buddy5mo ago
But that isn't your issue really. Just a quick optimization / recommendation. And prefer to cache the components as using GetComponent is expensive.
Rosor
RosorOP5mo ago
?
Buddy
Buddy5mo ago
So do like you did with RigidBody2D but with Collider2D. In the Start method
Rosor
RosorOP5mo ago
yes and ok but what I must change than
Buddy
Buddy5mo ago
As for your issue. Does it give you any errors?
Rosor
RosorOP5mo ago
no
Buddy
Buddy5mo ago
No errors in Unity's console?
Rosor
RosorOP5mo ago
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.
Buddy
Buddy5mo ago
Rename your variable to something else. I usually go for _rigidBody when it comes to that warning.
TheRanger
TheRanger5mo ago
Debug, ensure Physics.Raycast returns true
Want results from more Discord servers?
Add your server