Hello,
I’m searching for a way to detect an actor in a vector but I can’t find anything to help me.
I wanted to do a function which makes my character hit an ennemy in front of him. To do that, I try to create a vector starting from him (when he strikes) and if an actor (an ennemy) is detected in the vector, I call an other function (for the damage). But I don’t see how to make the detection in my code with a form like :
if (actor in vector)
{
actorTouched = actor;
damageFunction(actorTouched);
}
What you’re looking for is a trace. You can use any of the trace functions in UKismetSystemLibrary, such as LineTraceSingle, or perhaps BoxTraceSingleForObjects depending on your preference, and if you want to have a very accurate trace or some lenience. If you’re using blueprints, you can also use the same functions, for example: