C
C#6mo ago
Rosor

why I can not jump

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