Jumping on enemies Mario-style.

Can anyone help me out with how to take out enemies by jumping on their heads i.e. Super Mario?

I’ve found a couple of tutorials on YouTube like this one but the problem I have with all the ones I’ve encountered so far is that they all seem involve placing a collision box on top of the enemy. The reason that this a problem for me is that if the player were to land on the enemy’s face instead of the top of their head then the player would take damage. I would much prefer that if the player lands on the enemy’s face/backside/whatever with a jump it should count as a hit on the enemy rather the player.

So to accomplish this, I decided instead to try and attach a collision box to the bottom of my character, using these tutorials I found Link #1] Link #2] to setup the collision between the player and a cube standing in for the enemy. The aforementioned tutorials were intended for setting up a punching attack but I figured it could be modified to suit my own intended purposes.

Unfortunately though, the collision between the player and the “enemy” box isn’t working as the way that I hoped. For example, when the player lands on top of the enemy’s “head” near the middle, the player lands without registering a hit or bouncing off the “head” of the enemy. A hit will only register if the player instead lands near the very outer edge of the cube for some reason. Similarly, if the player runs into the “enemy”, nothing happens, which is what ideally should happen but for some bizarre reason if the player turns around then they are bounced away from the “enemy” box with a hit registered. So clearly something is wrong with the way that the jumping collision box is setup and I need help with identifying what’s wrong.

I was also wondering if I need to do something to limit the collision with the jump hit box to the Z-axis in order to prevent it from dealing damage to enemies by running into them. As I previously mentioned, running into the “enemy” box right now doesn’t register a hit which is good but I’m afraid that it its result of whatever is causing the jump collision to not work properly.

As always, any help would be greatly appreciated!

Okay, I think I might have fixed both of the issues that were causing problems. For the first issue, I simply had to move the jump hit box down a little bit, while for the second one, I shrunk the Z-axis of the hit box to 0. After doing a bit of testing, there doesn’t appear to be any unfortunate side effects to my fixes, so hopefully this resolves everything.

However, I do have something else related that I hope I can get some help with. You see, in a lot of platformers that allow you to defeat enemies by jumping on them, the player can bounce higher off an enemy if the player is holding the jump button down when they make contact with the enemy. I would like to be able to do something similar for my own game but I’m not sure how to go about implementing it in my current setup.

Jump blueprint:

Jump collision blueprint:

So I’ve managed to make a bit of progress in my efforts to allow my player character to bounce higher off of enemies by holding down the jump button.

I added a boolean-type variable called *Jump Pressed *to my Jump node setup and then created a new branch within the Jump Collision setup that uses the newly created variable to trigger a Jump event if true and the already established Launch Character event if false.

Now with the newly modified setup my character will now launch into a full jump after landing on the “enemy”'s head while holding down the jump button, and simply bounce off of them a little bit if the jump button isn’t being held down.

However, there’s still some issues that need to be addressed. Firstly and most importantly, there’s a serious problem where the responsiveness of doing the full jump off the enemy is rather sketchy. If the player continues to hold the jump button down after doing the initial jump to land on the enemy stand-in then the character leaping off the enemy stand-in will always activate. However, if the player tries to hold the button just before landing on the “enemy” or just as they land, very frequently the character will simply come to a complete stop after landing on top of the box with neither a full jump or a small bounce.

The second issue is that I would like to use the variable height jump setup I have for the main jump function in my jump collision setup instead of simply using Unreal’s preexisting Jump event. Unfortunately, I don’t know how to go about accomplishing this other than maybe a custom event based on my variable height jump setup which might work, but once again, I don’t know how to pull that off.

I’m pretty sure that for the first issue that my setup for jumping off of enemies is extremely flawed, so I would welcome in any input on how it can be setup in a more sensible manner that would work in the way that I want it to. As for the second issue, like I said I don’t know how to incorporate my own custom basic jump setup into the jump collision setup beyond maybe using a custom event, or not, as I don’t really have enough experience for this type of thing.

I finally managed to get it to work, it turns the problem was the Jump node I was using since the Jump node doesn’t activate in the air which was causing the collision problems. Once I replaced the Jump node with a Launch Character node instead, the problem went away.

I was also able to incorporate the variable jump mechanic from the basic jump setup by using the Jump Pressed boolean variable I created. I set up the variable to trigger a Branch that would initiate a Launch Character event that would then interrupt my character’s upward trajectory if the Jump Pressed boolean wasn’t active.

So everything is now working, I would say thanks for all the help but no one responded to my topic so I’ve been talking to myself this entire time. Oh well, hopefully this topic will be able to help others who have also run into this exact same problem.