How to update the animgraph of a non-player controlled character?

Question:

I would like to understand how to trigger the transformation of a bone of a non-player controlled character (“NPC”) when I press a key. My current ‘wrong’ approach is below.

Setup:

I am using UE4’s Third Person Example and have two ThirdPersonCharacters in the map, one controlled by me and the other an NPC. Both characters share the same default ThirdPersonCharacter blueprint, default ThirdPerson_AnimBP and default UE4 mesh and skeleton. Essentially identical except I control one of them.

Goal:

Upon the occurrence of a certain event (e.g. pressing the “L” key), I would to rotate the bone of the NPC. I have been able to achieve this with the character controlled by me (see screenshots below) but not the NPC.

I am not sure where I am going wrong, but my assumption is that I somehow need to cast the new rotation value to the NPC character? How is it possible to choose which character the AnimGraph updates (e.g. why is it my controlled character and not the NPC despite the fact that they both share the same graph/blueprint).

Current approach:

In the ThirdPerson_AnimBP animation blueprint, I currently use “Get Pawn Owner” to obtain the target Anim Instance object and then cast the new bone rotation value to “ThirdPersonCharacter”.

My guess is that this is where I am going wrong and that I need to cast to the NPC somehow by ‘getting’ an Anim Instance object reference to the NPC? I am not sure how to do this…

My other guess is that I need a different animation blueprint for the NPC, since it is not clear to me in the Anim Graph how to apply a bone update to one character (e.g. the NPC) and not to my controlled character.

In the AnimGraph, I then use Transform (Modify) Bone to set the new bone rotation.

In the ThirdPersonCharacter blueprint, by pressing “L”, I set the rotation variable for the bone I want to adjust in the AnimGraph.

Hey, I never thought of this (never had a reason to do what you’re doing) but my guess is it must be because the other character is not directly controlled/possessed by your player controller so it’s not ‘listening’ to input. Not sure if you have specified that it should be possessed by AI? (it probably does get AI-possessed automatically).

You don’t need to cast to anything, because as you say, they are all the same type.
What you could do is get the 2 blueprint instances to communicate with each other during the game (done internally within the one BP that rules them both in the Editor). Maybe the blueprint has a variable that holds a reference of its own type, and you fill in the reference to the other character in the map. If you spawn both characters (so they don’t exist in Editor yet), then you could do a Get All Actors of Class node, find your blueprint type and execute the logic on all of the found actors.

Thanks so much for your help!