Help with Mario-style jump mechanics

So I’ve been trying to implement Mario-style jump mechanics into my game such as being able to control the height of your jump by how the long the jump button is held (a.k.a. variable height jumping), and being able to take out enemies by jumping on them as well as bouncing higher off of them by holding the jump button down while doing so. I’ve managed to work out the mechanics for the most part, except for two glitches I’ve encountered so far that need need to be dealt with.

The first is a glitch where the player can rapidly stomp an enemy by repeatedly jamming the jump button over and over again, which isn’t a problem for the majority of enemies since most of them go down in a single hit but it is a problem for any other enemy or boss that take more than one hit to defeat.

The second glitch however is a much bigger problem and the main reason for creating topic, as it is a problem of my player character occasionally taking damage while jumping on the enemy. I have no idea why is happening as I haven’t been able to identify any one consistent variable to explain the problem, with the glitch seemingly occurring at random.

I thought the glitch might be in some way tied to the variable height jumping mechanics as the glitch seems to occur much more often if the jump button is held down. was supported by my tests with a enemy designed for the player to bounce off their head continuously without the enemy dying, as when the player was bouncing off the enemy’s head without the jump button held down, the player never seem to take any damage. I even tried moving the player around back and forth as they bounced off the enemy as it walked forward, and as far as I can tell the player would never take damage, while in contrast, holding down or rapidly pressing the jump button on the same enemy would frequently result in the player taking damage.

However, my hypothesis has been undermined by a number of occasions where the player did a full jump from a distance onto an enemy’s head without the jump button held down and ended up taking damage, as well as times when the player character would fall off a platform onto an enemy & take damage without the jump button being pressed at all.

I just don’t know what’s causing problem, hence why I’ve come here for help.

Anyways, here’s the setup for all the jumping mechanics, first starting with the hit collision:

  • Item #1 is the collision capsule for the player character, if an enemy touches then the player takes damage.
  • Item #2 is jump collision box, which is actually more of a flat 2D plane rather than a box, attached directly below the collision capsule; if box comes into contact with a vulnerable enemy then the player will bounce off the enemy’s head and the enemy will take damage, with the player bouncing much higher if the jump button is held down.

You’ll also notice that there’s bit of a gap between the collision capsule and the jump collision box. The reason for is that I noticed that the farther the jump collision box is away from the collision capsule, the less likely that the player would receive damage from jumping on an enemy. However, I don’t want to move the collision box too far way from the main collision capsule, as for one I’m not entirely sure how much moving the box away from the capsule actually helps, as it could be a bit of Placebo effect at play. Also, my concern is that widening the gap might contribute to the problem by allowing the collision capsule to come into contact with the enemy’s head instead of the jump collision box if they come at the enemy from a downward angle.

Next is the blueprint for jumping as a whole, including mechanics for variable height jumping, as well as SFX while jumping.

And lastly is the Jump & Bounce function which is called upon in enemy blueprints to allow the player to be able bounce higher off of an enemy by holding the jump button.

As always, any help whatsoever would be greatly appreciated!

EDIT #1: I added more blueprints to help provide more context.

The first one I added is the Receive Damage portion from my player character’s blueprint. Here is where the logic for the player taking damage is set up and is connected to a custom event that can then be called upon within the enemy’s blueprint.

The second blueprint I added is the portions of the enemy blueprint related to the player taking damage from the enemy & jump collision. I thought I should also warn that the Receive Damage function targeted to the enemy is entirely separate from the Receive Damage custom event that handles damage to the player, I just didn’t give the two events different names.

I hope helps.

EDIT #2: I decided to add a more up to date version of the blueprint for the invincible test enemy replacing the basic enemy blueprint I posted before.

EDIT #3:
Unfortunately, I haven’t been able to find any solution for my jump collision problem as it appears that the Jump Collision Box simply can’t trigger fast enough before the player’s Capsule Component comes into contact with the enemy, resulting in the player taking damage.

So instead I’ve decided to go ahead and scrap the Jump Collision Box altogether and try line tracing for my jump collision setup, using the tutorial I linked in a previous post below [[Link][6]]. The idea I have in mind is to use the existing Null Damage - Player boolean to disable the Receive Damage custom event when the line trace hits the enemy. However, will also require having to set up a branching path where if the player’s line trace isn’t in contact with the enemy, then the Null Damage boolean is disabled so the enemy can do damage to the player. Does anyone have any suggestions on the best way of accomplishing ?

Hello Hungry Moogle,

can you give us some more information? As in, do you have any damage logic implemented, and where and when is said logic actually called?

Two simple solutions for your two glitches. Somewhat based on assumptions:


First glitch: Let the enemy have an invulnerability phase, right after he has taken damage. I assume that the cause of reoccuring damage is, that the “jump collision box” is still in contact with the enemy, when the player spams the jump button again. Letting the enemy have an invulnerability phase (like 0.2 seconds) ensures that the player has jumped away by then.


Second glitch: might be caused by the fact, that slight irregularities in tick timing and your jump animation, result in the “collision capsule” colliding with the enemy (making the player take damage), even when the “jump collision box” already collides with the enemy (which should propel the player away from the enemy).

The solution should be similar to the one for the first glitch: make the player invulnerable to the last enemy he damaged. way, you can even move the two collision capsules closer together.


As a side-note: maybe make the “jump collision box” smaller as the “collision capsule”. would ensure, that the damaging “jump collision box” does not collide when you run head-first into an enemy.

I hope was helpful and not too long winded

As per [TheKehlim][1]'s advice, I tried adding a brief period of invulnerability for the player when jumping on the enemy.

While it has reduced the frequency of the player taking damage from the enemy quite a bit, it hasn’t completely eliminated it.

In addition to what @TheKehlim mentioned, I suspect that another thing that’s contributing to both issues you mentioned is the fact that you’re applying a sudden downward force when InputAction Jump is released by calling Launch Character in order to make the character start falling. If you don’t have Continuous Collision Detection (CCD) enabled on your player collision, can lead to false positives where the player’s collision is moving very quickly so that it registers a hit with the enemy collision on one frame before being corrected in later frames, which would explain the second glitch. So try enabling CCD on your player collision first and see if it helps:

As for the first glitch (the player being able to rapidly stomp on an enemy), notice that in your InputAction Jump you’re applying both jump and fall forces without checking the current state of the player, so in the case where you start falling but then press jump quickly, the Pressed event will first apply upward velocity (jump) and counter the fall momentum, and that is quickly followed by a large negative velocity (launch character) allowing the player to stomp on the enemy.

I think finding a way to let the player begin falling without using Launch Character will help with both glitches. There are several approaches you can experiment with such as [these][2]. Hope that helps.

When you say enable Continuous Collision Detection on the player’s collision do you mean the Capsule Component, the mesh itself or the Jump Collision? I wasn’t sure so I tried enabling Continuous Collision Detection on all three to see if that would help, unfortunately though, it didn’t really seem to make much of a difference.

As for the issue of the Launch Character node, I’ve suspected from the beginning that it was causing at least some of the problem since the player would noticeably take damage much more often when the jump button was being pressed. However, how do I make the player fall without the use of the Launch Character node? Unreal Engine 4’s built-in Stop Jumping node doesn’t cancel the player’s jump when the jump button is released and I’m not sure what other alternative there is. I tried looking at the thread you posted but everything suggested within it goes way over my head.

Yes, I meant on the player’s capsule component, and I think it should be enough to enable it on just that one component. Try increasing the Position Solver Iteration Count as well which is under the Physics section. You might not end up relying on changing those values to fix the problem but you can use to identify whether the capsule collision moving downwards too quickly is really the issue.

As for making the player fall without using Launch Character, one of the approaches is to increase Gravity Scale which will pull the player downwards more quickly/strongly. However, will also make jumping harder so the solution proposed in that link is to use a timeline to start increasing Gravity Scale when the player jumps but then reset it to the default value when the player lands so that jumping is not affected.

Here’s an example of where increasing Position or Velocity Solver Iteration Count can help.

Oops, I forgot to add the invulnerability phase to the invincible enemy I created specifically for testing the jump mechanics. I only added it to the non-invincible enemy that I plan to include in the final version of my game. Unfortunately, while it helps somewhat it still doesn’t solve the problem in its entirety.

As per m_foda’s advice, I tried retooling my jump setup using the one described in the fifth post of topic on the Unreal Engine Forums as a starting point.

Unfortunately, my character still takes damage from jumping on the enemy even when the jump isn’t being held down. So what else can I do now? At point the only thing I haven’t tried so far is changing the Position Solver Iteration Count, as I don’t know what it does and I’m reluctant to mess around with something that I don’t know the functionality of.

Hello Hungry Moogle,

You could try to check for the vector of impact and the current player velocity, might be more of a band aid than an a good solution. To explain what I mean by that, if the player is currently above the enemy, (player location z >> enemy location z, considerably greater something in the vicinity of half the height of the enemy) and the velocity is downwards the player shouldn’t take any damage.

But back to the original problem does the player actually gets launched upwards, because it seems like the player stays on top of the enemy for a couple of frames, hence taking the damage, and doesn’t get launched when the player jump hitbox hits the enemy, have you checked if the jump and bounce function gets called?

I’m not sure what you mean by the player being launched.

How the invincible test enemy blueprint is set up is that when the player character’s Jump Collision Box comes into contact with the enemy’s Capsule Component, the Null Damage - Player boolean variable is activated so the player won’t take damage (in theory at least) and then the Jump & Bounce function is called.

The Jump & Bounce function then launches the player off the enemy, with how high the player is launched being determined by whether or not the jump button is being held down at the time, as setup here in the Jump portion of the Player Controller blueprint:

Once the function is called, the visual effects for the player landing on the enemy play and finally there’s a delay that will re-enable the enemy’s ability to damage the player once the delay has ended.

I’m not sure why the player is taking damage as the Null Damage - Player boolean is supposed to prevent that from happening as it is positioned near the start of the Jump Collision events. The only way that would make any sense to me is that the player’s Capsule Component is somehow coming into contact with the enemy’s Capsule Component before the Jump Collision events are registering. If that is indeed the case then what can be done to stop that from happening?

Hello Hungry Moogle,

could you send us a picture if how the jump collision of the player is set up (the details panel, physics section)? I think there might be something wrong there.
Just an advice, I would try to not use the delay node, because if it is being called but still running the call will be ignored (i.e. not resetting the timer). Instead you could use the OnEndOverlap event to reset the null damage variable, but for that to make it work correctly the jump collider would have to be smaller than the player capsule.

Here are the Physics & Collision details for the Jump Collision Box:

Also I came across [][3] video tutorial on YouTube, where the person uses Line Trace by Channel for taking out enemies by jumping on them and I was wondering if it would be a good time to just scrap the Jump Collision Box idea altogether and instead retool my entire setup to use Line Tracing, or whatever the proper terminology is. I hasn’t used Line Trace by Channel so far, so any advice regarding idea, whether its a good or idea not & how to implement it would be welcome.