Reset JumpCurrentCount after stomping enemy?
I'm using a Character with a CharacterMovementComponent as my player in a game where the player can perform multiple jumps (limited by Max Jumps) before hitting the ground.
I'm able to detect when the player lands on an npc, and I want that to count as "hitting the ground" so they are able to jump again after bouncing off an npc's head in order to chain jumps.
Problem is, using the CharacterMovementComponent, I see no way to reset the JumpCurrentCount back to 0 so the player can start jumping fresh.
JumpCurrentCount is a read only integer variable in Blueprint and I see no way to reset it, set it to 0, or have the character think it is back on ground for a frame from within Blueprint. My Character.h file is also read only, so it doesn't appear that just changing that var to BlueprintReadWrite will work, and I'd rather not change a core header file anyways.
Any thoughts? I have the rest of my jump mechanics working well within the Movement Component setup but wasn't expecting this to be an issue. Thanks in advance for your help!
asked Dec 05 '16 at 12:57 AM in Blueprint Scripting
I came up with a basic fix that works pretty well:
The result is that if I land on an enemy, it'll count as "ground" for a frame, clearing my jump count, and the Jump() call will cause my player to bounce up. Then I can press jump again to double jump in the air, etc.
There are (literal) edge cases with this approach, if my method of detecting that the player landed on the enemy declares positive but the physics engine doesn't let the player step on the enemy because the angle is slightly off, but I think that can be cleared up by either:
a.) Making sure the collision event has the same parameters as the character's step angle b.) (haven't tried this yet) Doing a "Are you standing on this" check against the NPC before declaring a successful stomp
answered Dec 05 '16 at 06:18 PM
Without using your own jump counter I dont think there is anyway to do it other than making it a public variable.
answered Dec 05 '16 at 02:24 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here