Trace by Channel help?

So for a while now I’ve been trying to implement a way to take out enemies by jumping on them Mario-style without the player taking in the process for a long while now. After many, many failed attempts I finally found some success by using a Box Trace by Channel but while jumping on enemies now appears to work as intended, there seems to be an unfortunate side effect of setup.

Player jump collision blueprint:

Enemy collision blueprint:

When the player character comes into contact with the enemy from the either side, the player will be bounced upwards into the air. The bouncing itself is almost certainly being caused by the Jump & Bounce event I made, which causes the player bounce off the enemy when they land on them. The giveaway being that the “bounce” sound effect plays when the player makes contact with the enemy. event is only supposed to be triggered when the enemy comes into contact with the player’s underside from down below.

Jump & Bounce function blueprint:

My only assumption as to why event is being triggered when isn’t supposed to be is that the box trace I used for the jump collision isn’t limited to the downward Z-axis and instead triggers when the enemy comes into contact from any angle.

As a result, I was wondering if there’s any possible way that I could limit the trace to exclusively a downward Z-axis so that it won’t trigger when the player comes into contact with the enemy from the side, only from above.

As always, any help whatsoever would be greatly appreciated!

Rather than just a collision, how about a downward trace which requires the enemy to be below the player by a certain distance. The way, you can avoid the problem of a general purpose collision just triggering whenever you get near something.

Yes, that sound likes what I want to do, I just don’t know how you go about limiting the trace downwards.

Something along these lines:

So, always doing a downward trace of a certain length, but when it hits, check the distance between you and the opponent. It has to be in a certain range to call the damage event.

Also, put a DoOnce node in the enemy damage routine ( I don’t know if you have ), so that it only gets called once. Reset it when you’re ready, don’t bother if the opponent has been destroyed.

It’s not working, the jump collision is completely broken, at least using the box trace, if I use a line trace instead then its only mostly broken.

So here’s my setup. Yes, I know its a giant mess that needs to be greatly simplified, however at point in time I don’t know how to simplify communicating with multiple different blueprints.

Anyways, the jump collision is completely borked when it comes to the enemy blueprints, my player character takes damage from landing on an enemy without doing any damage to the enemy itself. However, if I substitute the box trace with a line trace like in your example, then the jump collision still works with the balloon blueprints I made but the enemy ones. The problem though with using a line trace is that I get all kinds of collision issues with the balloons unless the player lands dead center on top. is why I was using box trace to begin with as the line trace is simply far narrow to work properly. So unless there’s a way to widen the line trace then a box trace has to be the way to go.

What about using the box, but only use it to react if the line trace also pans out?

Ok, the trace it wrong. Is the actual BP you’re using? You need to connect


The way to avoid the casting nightmare is blueprint inheritance. If you had one BP that all enemies inherited from you would only need one cast :slight_smile:

I checked and the Vector Addition node wasn’t the problem.

Rather the problem appears to stem from something related to the Break Hit Result Location stuff, as jump collision still works with the balloons which are not connected. In contrast, the two enemies are connected and they’re the ones where jump collision isn’t working.

Ah you’re back to the box trace. I can’t help if you keep randomly changing things :wink:

You can use the box trace to tell when you are overlapping an enemy, but you need the downward line trace to know if the enemy is below you.

How do I do ? I don’t really have much knowledge on how to make tracing stuff work.

So, do your box trace as usual, just like before, but also use my line trace code, but just to print out the results ( was there something under you, what was it, how far ).

Then play the game and jump on stuff and generate your error, whilst looking at the output from the line trace, and see if you can find a way to use the line trace to solve your problem.

I’m sorry but I don’t know how to set up the line trace from the box trace in order to do as you asked. As I said before I don’t have much knowledge on how to make tracing stuff work.

So, with LineTrace I get a text shown in my Viewport which says what is under me. The LineTrace starts, when I release my Jump Key (spacebar).

With the second LineTrace I can do things when the Actors’ name (the actor under me) contains Enemy.

Okay, since I have absolutely no idea on what I’m doing, I just decided to apply most of [L1z4rD89][1]'s line trace blueprint into my jump collision setup just to see what would happen.

The good news is that the jump collision didn’t end up breaking but it didn’t fix the trace collision problem. On top of that, I’ve noticed that the area of the jump collision box trace has shrunk with my player character taking damage from jumping on the enemy if they land off-center.

I’m sorry but I really, really don’t know anything about setting up traces and I am completely lost.

You need to do your box trace, just like you always did. That worked, leave it as is.

When the box trace scores, THEN do a line trace to see if the intersected actor is indeed below you.

To see what you are doing, in your BoxTraceByChannel set DrawDebugType to ForOneFrame. way you can see the BOX which should be under your character.

With code, I get something like :

So BOX could be a little bit bigger than your character. When BOX is overlapping another actor (like my GOOMBA cube in hte example) it scores or fires. Then you whant to know, ok the BOX overlapped an actor, but is he also under me? Like :

And in game would look like :

I tried implementing your line trace setup as best as I could but I still can’t get the line trace to work. The plus side is that I’m not having any other collision issues pop up but my character is still bouncing off enemies, killing the enemy in the process, which shows that the line trace still isn’t working at all.

I have no idea on what I’m doing wrong.

I need help, please.

Ok, here: