Hi, I had some difficulties getting all of the references to the engine generated class instances at the beginning. Did you set the object reference to the character? Try this:
In your Animation Bp, use the “Try Get Pawn Owner” node and cast it to your character type (and save it to an object reference variable of that same type in you Animation Bp) you should now be able to use that reference to get access to the variables in your character instance (note: the animation blueprint is spawned (instanced) before its associated character, so the first few runs through “Event Blueprint Update Animation” will fail the cast until the character has been spawned):
An alternate way to do this is to create an initialisation function in your animation blueprint that will save a passed reference to you character, then in your characters “Event Begin Play” call that function (will have to use “Get Anim Instance” to get a reference to the animation Bp that was instanced for your character (defined in the character component > mesh > details> animation)) and pass it a self reference:
(Image Below: Character Event Graph)
Note: If you do this, you won’t have to do the cast and set in the top image, which will run every time the event triggers. You could also set a Boolean in the image below “PostInit” to true, then put a branch node after the update animation event that will only run the rest of the event code if PostInit is true (Image Below: Anim Bp function)
For future reference, the order in which engine created objects are spawned (instantiated):
Player Controller is instantiated and runs “Event Begin Play” before the Level Blueprint, Game mode, and Player State have been constructed (i.e. Player Controller will be created and run Event Begin Play before the Game Mode and Level Blueprint Construction scripts are run).
Also in “Ai Controller” blueprint, the “Get Controller Pawn” node which returns the character for whom this Ai has been instanced returns none from Event Begin Play". It only returns the valid character after Event Tick (again seems the Ai is instanced before the character). It seems this is also true for the Animation blueprint, when using “Try Get Pawn Owner” from the “Event Blueprint Update Animation” event, this will fail for the first few runs through the event until the character has been instanced.
This may seem back to front (trying to start the engine before it’s been put in the car). I would have thought ideally you would instance the level first, then the Player Controller, then the Players State, then the players character, then the characters Ai and Animation blueprints, but there’s probably a reason…
(Image Below: character AiController Event Graph)