Hello, I have a pretty complicated question even though it is actually a simple issue. I am trying to program a jump set up and I use ontrigger enter, stay, and exit to determine if the player can jump. I tried before with raycasts but it was giving us way too many weird behavior problems and each fix kept bloating the size of our code and giving more weird behavior problems so I eventually told the team to forget the raycasts and use pure physics, which work very nice.
Now the intended behavior is that when the player is grounded, the jump button adds force to the rigid body allowing it to jump, which that is what happens. Now there are two tags the player can jump off from, Floor and Enemies. Floor is static but Enemies are game objects that are navmesh agents and use a navmesh for their pathfinding to chase down the player. Enemies cannot jump so they stay on the ground or wherever the navmesh allows them to navigate to.
The bug occurs when jumping off of enemies. Occasionally, for some reason when the colliders exit, they don’t show false for isGrounded, they stay true instead and it allows the player to continuously jump and it constantly adds force since if u hold the button, it adds that amount of force to the jump constantly. This does not occur with the Floor unless Floor is a vertical surface which we have taken great pains to ensure we have no vertical surface marked Floor. It only happens with the enemies even tho both use the same code since the tags are referenced in the same methods. I have added a height limit so you cant go too high, it actually forces the player back down by using a velocity change to negative and it turns isGrounded to false. However, its a cheap workaround and I would rather we eliminate this weird “flying bug” completely so that our jump mechanics can work as intended.
So tl;dr, the player flies continuously upward off enemies until hitting the height limit because for some reason isGrounded is still flagged true upon exiting the colliders even tho the code shows it is supposed to be false on exit. Does anyone have any ideas or suggestion as to why this is happening? Thanks.