C
C#4mo ago
Rosor

why I can not jump

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