How to detect collision between sword and character?

Hi !
I would like to say in advance sorry for the mistakes, I am French and my english is not perfect…

I do a multiplayer project. I am at the beginning of the project.
I have 2 players in an area that can move, see each other and attack with an animation.
My problem is to detect collision between my sword and the other character.

Some explainations :

  • The 2 characters in my game have the same blueprint : BP_Player.
  • My sword is in another blueprint and I attach it to a socket of my skeletal mesh (characters are both using the same skeletal mesh at the moment)
  • When a player press the left button, then an event run on server is called. This event then change my variable “is attacking” to play an animation (in the Anim BP). So, it is in the run on server event where I would like to detect if I have hit somebody.
    Consequently, I can’t use the “event begin overlap” because I need to be in the run on server event…

So, I tryed to use the node “get overlaping actors”. I select in it the class “BP_player” to filter. It wasn’t working. So I try to see if they were something in my array by checking what was the last index of my array. I quickly find that they were nothing in the array…

Have you an idea of what I can do ?

Thank you very much for your help

Have a good day

I found a part of the solution ! The “is overlaping actor” wasn’t working because I hadn’t enable the “generate overlap event” in the sword mesh and in the skeletal mesh ! So I check this and now it is detecting that the bp_player1 and the bp_player2 are in collision. It wasn’t was I would like to do (i would like to test collision between sword and character…) but it is a part of the solution. If someone has an idea to how I can say that I would like to detect the collision between sword and player2 and not player1 and player2… Because I don’t know to select the sword to test overlaping…

EDIT : I manage to test overlapping between sword and character by using “get overlapping actor” node. But at the end I realised that this kind of test is only done one time (because my event that call this node is call only once himself).
So I need some help please :

  • I need to find a solution to test during all the animation the overlapping actors.
  • Or I need to find another solution.

Thank you in advance for your help

if you want it to do something for each frame/tick that the sword overlaps, then check on that during the Tick event, and multiply calculations by delta time to correct for different framerate.

Thank you for your answer ! Since I posted my last message I finaly did an event tick ! And it is working now. But I have just a question about what you are saying, I didn’t understood well what you said about delta time. I know that I have a delta time in my event tick, but i don’t use it. For what do I need to use it ?
And another question : is there a way to do something every second or things like that ? instead of each frame like event tick.

Thank you again for your answer !

Delta time is the “real time” between ticks so using that value as a correction factor will give you a constant “result” for whatever is running off tick. For example if you wanted something to rotate on tick and told the engine to update the rotation of an actor by 6 degrees each tick and you had a frame rate of 60 FPS you would end up with

6 degrees per tick * 60 ticks per second = 360 degrees per second

Now say you have a frame rate of 30, your calculation now becomes

6 degrees per tick * 30 ticks per second = 180 degrees per second

In the first example your actor rotates a full 360 degrees, in the second it only rotates half way around. So it would actually be facing the other direction when compared to the first actor running on 60 FPS.
So the “delta time” corrects for this by standardizing a “tick”. It will make the new calculation as follows

For 60 FPS you would have the following

6 degrees per tick * delta time (1/60) = 0.1

6 degrees per tick * 60 ticks per second * 0.1 = 36 degrees of rotation per tenth of a second

For 30 FPS you would have the following

6 degrees per tick * delta time (1/30) = 0.2

6 degrees per tick * 30 ticks per second * 0.2 = 36 degrees of rotation per second per tenth of a second

Now both actors rotate 360 degrees in 1 second.

As for your other question, yes! You can use “timers” they will allow you to set how long to wait before looping an execution pathway. So you can set the “delay” to be 1 second or whatever you like.