C
C#7mo ago
morba3Xdwara

❔ unity single jump

Hi, I need some help about jump mechanics in unity, I have written a code that suppose to make the player do a single jump but he double jump instead. If does someone and idea why, I will appreciate him.
No description
10 Replies
Tvde1
Tvde17mo ago
might the Update be executed => force is added => OnCollisionStay is executed => isGrounded = set to true then the next frame loads? in the next frame, the player moves but isGrounded is true?
morba3Xdwara
morba3Xdwara7mo ago
@Tvde1 first OnCollision be executed => Update then isGrounded = false => isGrounded is true "when I'm not touching anything" => Update is executed while I'm in the air
Tvde1
Tvde17mo ago
is that always the way it is?
morba3Xdwara
morba3Xdwara7mo ago
probably
Tvde1
Tvde17mo ago
did you measure it or is that an assumption? because bugs are caused only by bad assumptions
morba3Xdwara
morba3Xdwara7mo ago
sorry I am new in game development, can you give me a simple code.
Luken
Luken7mo ago
are you using threads? maybe try to put isGrounded = false before the addForce call you might be reentering the update function before isGrounded = false
Murten
Murten7mo ago
It's not. There's also $unity
Accord
Accord7mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts