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 ?