How to Cast to NPC?

Hello,

So I am trying to do a basic function. I press the “9” key, and have an NPC play an animation. I have my cast setup below, but the NPC will not play the animation.

If I bypass the cast, the animation plays on my character fine as the ‘target’ goes to ‘self.’ I’ve spent the past few hours trying to understand how to cast to anything other than the main player character and I still cannot find the answer. Why is it with any other process like line-tracing, the cast function finds the NPC no problem, but a simple command doesn’t go through. This is the only NPC with the name “TreningDummyDialogue.”

I have already tried the method below following another solution I read on AnswerHub but that did not work for me as the error in the image pops up. Yes, the NPC does inherit of the class I am trying to get all actors from.

I’m using a default project from the Dynamic Combat System so I’m not too sure about what the game mode is and things like that. I’m still on the newer side to Unreal. Thank you in advance for the help!

If your code is in Level Blueprint you can primarily reference actor:

  • select Actor that you want in World outliner
  • open Level Blueprint
  • right mouse button, search for “reference” and scroll to first items, there will be something like Create a reference to …

Also, solution for an error is rather simple - just use BP_TreningDummyDialogue class in GetAllActorsOfClass node

Hey so I tried both the reference in the Level Blueprint and the fix you suggested in the GetAllActorsOfClass but I still can’t get the animation to play. Did I set everything up properly?

Level Blueprint:

Simple Solution (inside main character BP):