Help improving my Mario-style jumping setup

For a while now I’ve been trying 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, but I’ve been plagued with problems of my player character occasionally taking damage while jumping on the enemy. In order to fully explain what is very likely happening, I’ll first need to explain the setup of the jumping & damage mechanics, starting first starting with the player’s hit collision:

1.) is the collision capsule for the player character, if an enemy touches then the player takes damage.
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.

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

And 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:

Next up 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:

And lastly is the portions of the enemy blueprint related to the player taking damage from the enemy & jump collision. I thought I should also point out 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 bother to give the two events different names:

Sorry for the long-winded explanation but anyways, the reason that the player is taking damage when they’re not supposed to is that the player’s collision capsule is coming into contact with the enemy when it shouldn’t. The jump collision box in addition to dealing damage to the enemy is supposed to prevent happening by bouncing the player upwards upon the jump collision box connecting with the enemy’s collision capsule.

I’ve been told somewhere else that the likely culprit behind glitch is irregularities in tick timing, which I suspected might be the issue as I noticed that putting space between the jump collision box & the collision capsule appears to reduce the frequency at which the player takes damage from jumping on the enemy.

To remedy problem, I tried to number of things that were recommended to me such as adding a brief period of invulnerability for the player when jumping on the enemy and enabling Continuous Collision Detection (CCD) on the player’s collision capsule. Adding the brief invulnerability period did help a bit, it hasn’t completely fixed the problem, while Continuous Collision Detection’s effectiveness isn’t really obvious.

Also likely tied to problem is another glitch I’ve been experiencing where if I press the jump button in rapid succession while bouncing on an enemy results in the player bouncing rapidly in a manner that shouldn’t be happening. The reason I suspect glitch is related to the other one is because I’ve noticed that the player is far more likely to take damage while the jump button is being held down. particular glitch is almost definitely the result of the Launch Character node that is used to control the jump height of the player character when the jump button is released. I’ve been told elsewhere that node is very likely a major contributor to the irregular tick timing issue and should be replaced by something else.

The problem with though, is that I don’t know what else I could replace the Launch Character node with. Unreal Engine 4’s built-in Stop Jumping event doesn’t cancel the player’s jump when the jump button is released, while other solutions I’ve seen involving playing around with gravity & using timelines go way over my head and so I’m unable to implement these solutions myself.

I was also recommended to increase the “Position Solver Iteration Count” but I’m rather hesitant to play around with values I don’t understand what their function is.

So does anyone know how I can control the height of my player character’s jump by how long the jump button is held down without the use of the Launch Character node? Or any other methods of how I can better optimize my setup so that the player character no longer takes any damage from jumping on an enemy?

Any help with matter would be greatly appreciated!

Can anyone please help? :frowning:

I noticed that I forgot to add the brief invulnerability phase for the player upon jumping on the invincible enemy I made for testing purposes, only applying it to the other proper enemy I made. Unfortunately though, adding the missing invulnerability phase only appears to have reduced the frequency at which the player took damage from jumping on the enemy & not eliminate it altogether.

At point the only options I see available so far are increasing the “Position Solver Iteration Count” which I still don’t know what it is, and retooling my jump setup to get rid of the Launch Character node, which apparently is contributing to the problem. I just made a recent attempt at redoing my jump setup using the setup recommended in topic, but it hasn’t gone well:

The problem I’m having with setup, besides my character jumping way too high (necessitating changing their personal gravity, which in turn causes all sorts issues that need their own solutions), is it that my character is still taking damage as they did before, even when I’m not holding the jump button down.

I absolutely cannot have glitch in my game, but I just don’t know what to do, everything I’ve tried so far either seems to only reduce the frequency at which the glitch occurs but not eliminate it altogether or does nothing to alleviate the problem.

As far as I can tell, the root of the problem seems to be that the Jump Collision Box’s events aren’t responding fast enough to launch the player character into the air before their Capsule Component comes into contact with the enemy’s, resulting in the player taking damage. If is indeed the cause of the problem then I need to somehow fix the response time of the Jump Collision Box so that it’s events will fire off immediately every single time it comes into contact with the enemy, as opposed to right now where the response time appears to be rather inconsistent.

Does anyone know how I can improve the Jump Collision Box’s response time? I’ve already enabled Continuous Collision Detection (CCD) on the player’s collision capsule, so what else can I do aside from maybe changing the “Position Solver Iteration Count”, although I still don’t know what that is and whether or not if that’ll be enough to fix issue.

So please provide any help that you can if you’re able, I desperately need the help.

I’ve read through your problem here and all I can say is that I agree that it (at least in part) has a lot to do with the planar jump collision box. Is it possible that the collision boxes on either the character or the enemy are firing more than once? If so, maybe a “doonce” node might help?

I don’t know, how would I go about finding that out?

I guess I’ll check out along with whatever “Position Solver Iteration Count” is, since I don’t really have any other options available at moment, so I’ll take whatever I get. Thanks for the suggestion.

Sorry, I’m pretty new at all . Fast motion + small collision box = problems… and I’d guess that CCD will help, but in extreme circumstances it just won’t be enough. A finer iteration sounds promising too, but yeah… I really don’t know.

So how did the developer Good-Feelmanage to accomplish in Yoshi’s Crafted World, which was made with Unreal Engine 4? I don’t know how jumping on enemies is done by professional game designers, so I just decided to use tutorials for melee combat like as the basis for my own jump collision attempt. However, since it appears that what I’m trying to do is simply too much for Unreal to handle, I was considering the possibility of scrapping the entire Jump Collision Box setup I have right now and instead try Line Trace by Channel.

In video tutorial here, they use Line Tracing for taking out an enemy by jumping on them, so I was wondering if would possible to use Line Tracing to create a setup that would override the player’s damage collision with the enemy if the Line Trace (or whatever the proper terminology is) comes into contact with them from above. I’ve never used Line Trace before so I’m not sure of the feasibility of my idea or how to set it up, so any input would be appreciated.

Awwww… now your just forcing me to learn stuff! LOL!

I’ve decided to go ahead and try use line tracing for my jump collision setup, using the tutorial I linked in my previous post Link]. 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 ?

Can anyone help because I’ve never used Line Trace by Channel before and I can’t find any examples of how to do a “else” condition for a line trace.

Okay, after watching the whole video tutorial and contemplating how to re-tool the whole setup, I think I’m more lost than I initially thought I was. I’m having trouble trying to figure out how to get the player’s Line Trace set up in a way that can then be called upon in enemy blueprints when contact is made.

I just simply don’t know what to do, I’m in way over my head with all Line Trace stuff and I am in a desperate need of aid.

Please help :(.

I’m not sure if helps but here’s a screenshot of the Line Trace as it set up in the tutorial I’ve been using.

Can anyone please help, I have no idea what I’m doing :(. Its been well over a month and I still hasn’t had any luck in trying to figure out how to use line tracing for jumping collision.

To reiterate what I’m trying to accomplish, I’ve been trying to create a branching condition where if the line trace detects a hit from the player jumping onto an enemy then said enemy will take damage, while damage to the player from colliding with the enemy will be disabled as long the player is making contact with the enemy.

I tried looking at other tutorials on line tracing such as one Link] for help to see if I could work something out but no such luck thus far.


I thought I could follow previous example and create a Branch event connected to the Break Hit Result in order to set up the branching events from the line trace, but it appears that you can’t directly connect a Branch event to the Break Hit Result. As a result of , I’m stuck with no clear path forward and I just don’t know what to do now. The only tutorial I’ve found on using line tracing for damaging enemies by jumping on them, is one Link], which is far too simplistic for my needs.

So how I do I use line tracing for jumping on enemies? I I desperately need help, as I have no others idea on what else I could do or where else I could turn for help.

I know it can be frustrating knowing what you want to do, but it being just out of your grasp. I had the same thing happening to me for a couple months over a relatively small feature. I don’t have an answer for you just yet, but wanted you to know that you aren’t alone in any of . I’m not an expert in any of these things, but I’m looking into your issue to see if I can be of any help. That being said, if anyone out there is reading has some suggestions it would go a long way to chime in to at the very least let the OP know he’s not just flapping in the breeze.

Okay, so over a year later I’ve finally managed to make some progress but I still some have issues that I need help with.

Firstly, I got the line trace to work but it appears that my player character will still take damage from jumping on the enemy if they don’t land dead center on the enemy. would seem to imply that the line trace is far too narrow, so I tried swapping out LineTraceByChannel with BoxTraceByChannel instead, which does seem to improve things a bit but I still feel that its not wide enough to keep the player from taking damage when they shouldn’t be.

Secondly, I have an issue where if the player runs into the enemy, the player character will then be bounced upwards which shouldn’t be happening. The source of the problem appears to be the enemy’s jump collision events being triggered by the trace coming into contact with the enemy, which should only be happening if the player’s Z-axis comes into contact with the enemy. However, the trace appears to be triggering regardless of which direction the player comes into contact with the enemy.

Does anyone have any idea on what I can do about either of these issues?

Player jump collision blueprint:

Enemy collision blueprint:

I think I might have at long last fixed the problem of taking damage from the enemy when jumping on them. After experimenting with changing the values within the box trace’s Half Size, I haven’t had any incidents since with the player taking damage when aren’t supposed to.

However, I’m still having problems with the player character bouncing upwards when they collide with the enemy from the sides. The bouncing itself is almost certainly being caused by the Jump & Bounce event that is intended to cause the player bounce off the enemy when they land on them, the giveaway being that the “bounce” sound effect plays when the player runs into the enemy.

Enemy blueprint:

Jump & Bounce function blueprint:

The entire jump collision setup is supposed to trigger when the enemy comes into contact with the player’s underside from down below, but it would appear that the trace isn’t limited to the downward Z-axis and instead triggers when the enemy comes into contact from any angle.

Is there any possible way that I can limit the trace to a downward Z-axis?