Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnLandEvent() Triggers Prematurely #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

OnLandEvent() Triggers Prematurely #3

wants to merge 1 commit into from

Conversation

tyirvine
Copy link

By leaving the line m_Grounded = false; in the statement if (m_Grounded && jump) it will cause in some cases for the OnLandEvent() to be triggered prematurely. This is because when m_Grounded = false; it will cause wasGrounded to be equal to false and therefore trigger the OnLandEvent() when m_Grounded = false; and therefore wasGrounded should actually equal true because it was grounded previously.

By leaving the line `m_Grounded = false;` in the statement `if (m_Grounded && jump)` it will cause in some cases for the `OnLandEvent()` to be triggered prematurely. This is because when `m_Grounded = false;` it will cause `wasGrounded` to be equal to false and therefore trigger the `OnLandEvent()` when `m_Grounded = false;` and therefore `wasGrounded` should actually equal true because it **_was_** grounded previously.
@gpressutto5
Copy link

It solved my problem!

@HarryWhitelegg
Copy link

This solved my jumping problem but now my character is constantly crouching plsss help

@tyirvine
Copy link
Author

tyirvine commented Mar 5, 2020

@HarryWhitelegg

I haven’t looked at this in a long time but your character shouldn’t be crouching based on whether or not they’ve made contact with the ground

They should be crouching if they’re touching the ground and the appropriate key or button is being held down as well

Just use an && operator to require both statements be true before running through the if statement

So

if ( (grounded == true) && (keyS == true) ) {

crouch = true;

}

else {

crouch = false;

}

Something like this ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants