2d paper, stop jumping midair (due to hitting a block and destroying it)

So i just started with unreal engine, and so far I love it, found some amazing tutorials online but one thing I havent been able to solve is how to hit a ‘breakable block’ (think mario when you destroy blocks by jumping under them), I managed to make a poor script killing enemies by jumping on them using 'Sphere trace by channel, so i added it slightly under my character and if it hits the object, kill it)

But when having a breakable block, if i would use the same method, the block would break and i’d pass through it, so I need to be able to tell my character that this particular jump, has ended.

Also when using ‘sphere trace by channel’ it ends up being in the middle of the charater, so if you are on the very edge of an enemy, the sphere will never hit the enemy thus you can land on it and die, i never found a workaway aronud it yet…

Here are the screenshots of me checking if an enemy is killed:

Is this the proper solution i should use? If so how would you solve to stop jumpnig midair, or is there some other way? Links to idea, tutorials, a point in the direction, i’d love any help I can get!

I could hardly follow all that, but to make a character stop moving, get the movement component and then use the SetVelocity node to make it 0,0,0 The character will stop and then gravity will pull down on them as normal unless you also do something to counteract it.

Well a few things. First of all to fix your issue with the sphere being in the middle of your character you can (instead of the actor location first calculate the lowest point of your character (“Get Actor Up Vector” → multiply with negative “Get Half Capsule Height” (simply by multiplying that with -1) and then add that to your character location). Then for the radius just use the same one as your capsule component (which you can get as well) and it should be impossible to not hit the enemy.

For your current issue… you could do a simple “Single Line Trace” and pass down an interface event and in any way set your Z velocity to 0 as Furroy said (which you can do via “Get Character Movement Component” → “Set Velocity” = “Get Velocity” → “Break Vector” → “Make Vector” (X = X, Y = Y, Z = 0) and then if the block you hit implements the interface do whatever (spit out a coin, destroy… whatever :wink:

I hope this helps.

Cheers

Thank you both, that did the trick!