[2D-Sidescroller] Enemy death on head stomp

Could anyone please help me on what I need to do? I would like for the enemy to die when the player stomps on its head.

I have just started using Unreal Engine and wanted to create a simple mario-like game.

You are on the right way but I would suggest you try out some basic Unreal tutorials to learn how things are done in unreal.

  1. To check if an Actor inherits from a special Actor class you just need to use the “Cast” node, it has an output when the cast was succesfull and when it failed. So instead of comparing the Actors classes like you do, just cast the “Other” to the EnemyActor class and fire EnemyDeath event on it.
  2. The Start and End Location of the Trace nodes are absolute world coordinates, so if you want to trace straight down you need to add the negated Up Vector to your Actors Location to get the right world location
  3. Unreal uses cm as units, in your case you just trace 1cm down, which is almost nothing, just multiply the Up Vector with something bigger, -10000 insted of -1 for example.
  4. Better use a Sphere Trace instead of a Line Trace, if just an edge of the player is over the edge of an enemy, the Trace would fail.

I hope this leads you in the right direction, there may be other ways to do what you want, espacially how to determine if a player hits the head of an enemy but try to make your way working, then you can improve it.

Thank you for your help with my situation. I am going to start watching those basic tutorials once I am able to. Those are the ones from the website, right?

Anyways, I’ve understood what you meant on 2-4 but I can’t understand what I’m supposed to be doing for the first one. I know I’m supposed to change GetClass and ClassIsChildOf to something but I do not know what I’m supposed to change it to.

Thank you again for helping me with this.

It is easier then you may think, just make a right click somewhere in your graph and type the name of your enemy Actor, unreal will suggest you a cast node which you can use. Take a look here.

I can’t seem to really understand most of the things properly so I think I will go and watch the tutorials first then come back to coding this one. I thank you again for helping me with this, I really appreciate it. :smiley:

If you have a programming background, this is very simple but don’t get frustrated, this is easier than you might think and with a little learning you will get it.