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.