OnLandEvent() Triggers Prematurely#3
Open
tyirvine wants to merge 1 commit intoBrackeys:masterfrom
tyirvine:patch-1
Open
OnLandEvent() Triggers Prematurely#3tyirvine wants to merge 1 commit intoBrackeys:masterfrom tyirvine:patch-1
tyirvine wants to merge 1 commit intoBrackeys:masterfrom
tyirvine:patch-1
Conversation
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.
|
It solved my problem! |
|
This solved my jumping problem but now my character is constantly crouching plsss help |
Author
|
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 ^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By leaving the line
m_Grounded = false;in the statementif (m_Grounded && jump)it will cause in some cases for theOnLandEvent()to be triggered prematurely. This is because whenm_Grounded = false;it will causewasGroundedto be equal to false and therefore trigger theOnLandEvent()whenm_Grounded = false;and thereforewasGroundedshould actually equal true because it was grounded previously.