x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.14
Tags:
more ▼

asked Dec 05 '16 at 12:57 AM in Blueprint Scripting

avatar image

JBernhelm
6 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I came up with a basic fix that works pretty well:

  1. I set my NPC's capsule collision to CanCharacterStepUpOn = (Owner)

  2. After detecting that my Player has collided with an NPC near the player's feet, I kill the NPC and call Jump() on my player

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

more ▼

answered Dec 05 '16 at 06:18 PM

avatar image

JBernhelm
6 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Without using your own jump counter I dont think there is anyway to do it other than making it a public variable.

more ▼

answered Dec 05 '16 at 02:24 PM

avatar image

Windex
26 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question