Download

Activate AI / NPC Animation by line tracing?

Is there a way that I am able to activate an AI / NPC to animate whenever I look at a certain place, im still new to Unreal so would be a massive help if there was a tutorial out there. Thanks in advance!

Here is an example where I use the the first person template and interfaces.

1 - create an interface BP (DoSomethingInterface) and name a function “PlayerTaggedMe”, for example.

2 - in your NPC or AI character add the interface and implement the event “PlayerTaggedMe”:

3 - in your player, create the a linetrace (1000 units in length). In this case, it everytime I press X, it will linetrace from the Sphere located at the gun’s muzzle (you can also use the gun), check if the hitted’s actor implements the interface, triggering the “PlayerTaggedMe” event (in this case it will only print Hello, but in your case, you should set to play the animation you want):

PS: note that the Trace Channel in the linetrace is set to camera and not visibility.