Why making a "cast to target_blueprint" in animation BP fails?

I am trying to access a variable from target blueprint in my animation blueprint. But it doesn’t work and I don’t know why.

Is MEMEME a pawn?

It is a trigger box blueprint, child to a pawn. But I also tried making a cast to the pawn blueprint itself. Doesn’t change anything.

Try doing an IsValid on the TryGetPawnOwner and see if it’s valid - maybe for some reason, it’s unable to get the pawn owner. At least confirm that you’re not trying to cast a None…

It realy is not valid. But why?

Does this occur when you are in gameplay or simulation? I don’t think you will see what you expect in preview mode.

In standalone mode it doesn’t print anything, though it doesn’t work. It either cannot cast (but doesn’t print) or doesn’t bring a variable.

Try dropping an instance of your pawn into the level if you haven’t already done so. Set its animation to run off this animation blueprint. Run the game in the PIE and see if it finds the pawn. Switch to debug the instance of your skeleton in the animation blueprint editor here. If TryGetPawnOwner is returning invalid, it is because there is no pawn attached to the script you are debugging. Animation blueprints run off a different process than the regular blueprints, so when you are developing the animation blueprint, it will look like it is running, but that is the preview skeleton. You can set values in the preview skeleton, but it’s not getting them from a pawn, so TryGetPawnOwner will always be invalid in preview/development mode, rather than running in PIE.

TryGetPawnOwner return invalid when I run in PIE. but there is a pawn.

Another thing to check - are you using this blueprint from a Pawn or Character - I’m not sure what else to check without the context of your setup here, but it may be worth it to set it as a Character, like this

YourCharacter->SkeletalMesh->AnimBlueprint

A cast should only fail under a few conditions.

A) In your case “Try Get Pawn Owner” may be inaccessible. The function might be private, or may be getting destroyed, or for another reason can’t be called. Verify that it’s being called before moving on.

B) The return type on “Try Get Pawn Owner” is not of the MEMEME type. Make sure you’re trying to cast to the same type. For example: you most likely are trying to return a blueprint reference of MEMEME type.

C) The cast is returning empty or null – in which case your function is likely faulty. Before the cast do a branch true/false check on the “Try Get Pawn Owner”. For example: From the return node of “Try Get Pawn Owner” make the node “Object (equal)” or Object =. Leave the drop-down to the defaulted NONE. If your branch returns TRUE then you know your function is failing somewhere.

How are you faring on this?