C
C#13mo 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
Tvde113mo 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
morba3XdwaraOP13mo 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
Tvde113mo ago
is that always the way it is?
morba3Xdwara
morba3XdwaraOP13mo ago
probably
Tvde1
Tvde113mo ago
did you measure it or is that an assumption? because bugs are caused only by bad assumptions
morba3Xdwara
morba3XdwaraOP13mo ago
sorry I am new in game development, can you give me a simple code.
Luken
Luken13mo 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
Murten13mo ago
It's not. There's also $unity
Accord
Accord13mo 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