[Help] Making a dash that passes through enemies and damages them

So I’m attempting to create an ability that dashes a specific distance while damaging enemies the character passes through.

Getting the dashing part was easy, but getting it to pass through enemies and damage them is proving to be more complex than I anticipated. Right now, an enemy is just a cylinder or cube I placed in the level. Another issue I’ve been running into is if the end of the dash lands inside the enemy with make the player stuck. That’s a less important endge case at the momet though.

being able to pass through enemies and damage them seems to be really complex and some help would be greatly appreciated. I’m using the 3rd person template btw.

Thanks again,

Ok, so I can only talk about what I’ve done in my project. whether this works for you or not, I can’t say.

For my attacks I basically trace for the enemy, it’s a specific channel trace, it only hits enemies. It can also be done by overlap, which I have done but I found that less consistent based on speed etc. So as I do the sort of dash attack, I trace for the enemy over a period of time that the attack lasts. The trace hits the enemy, the enemy get damaged. I have some checks in place to prevent “overlap” so one enemy one hit. Basically all my attacks work like this, it’s one system I call as needed by any attack.

To dash through enemies I switch off collisions on their channel at start of attack and switch it back on at complete. I actually use this for general jumping and various other things because there are a lot of cases I do not want enemy collisions to happen. This really works well and getting stuck inside an enemy has never happened to me. By default if you end inside enemy collision, the engine will push them apart instantly. If you do not like this behavior you can make your own. You can detect overlap, then push them apart over time or simply only re-enable collision when appropriate… or whatever. The point is you can control that from your script.

Hi @Light1c3,

To expand on what @Obihb said, you can do a trace or use a collision volume.

The simplest way would be to create a collision volume around your Player that generates an overlap on a specific object type (say they are pawns) - everything else gets ignored. So on your EventBeginOverlap event, first check if the Other Actor is your enemy (can look for class type for example), then if its the enemy, check if you are dashing (maybe a bool?). Then, if you overlapped an enemy AND you are dashing, turn off your Mesh collision and damage the enemy (already have the enemy reference via Other Actor from the event).

On your EventEndOverlap enable collision on your mesh.

As far as getting stuck inside the enemy, there are many different ways of doing this, but a simple way would be to do a simple check. Create a bool and call it “CanStopDashing?” and make this true by default. When you Dash just before you end the dash check this variable - if True -> end dash; If false, keep dashing. Modify your Dash function / Event to include this.

Now, you can set CanStopDashing? = false when you overlap an enemy (use the EventBeginOverlap above). And make it true on your EventEndOverlap. This way, if you are dashing, overlap an enemy and try to stop the dash (but are inside the enemy) the variable CanStopDashing? will be false, and your Dash function will continue until this variable is True.

Im not infront of my dev machine, so Im going by memory here - hopefully the explanation makes sense. Let me know if you have any issues.

Hope this helps!