What's wrong with this 'cast to'?

I’m using this in an animation blueprint to cast to another animation blueprint (except ‘get anim instance’ is also plugged into ‘is valid’). It gets past the ‘is valid’ check, but the ‘cast to’ fails. (also the ‘cast to’ should actually lead on to something else) So what am I doing wrong here? All I want to do is call a variable from another animation blueprint!

Is the PlayerAnimBP a subclass of the AnimBP you try to cast? If not this won’t work.

I assume it’s not if that’s a possible reason. So what would I have to do to it to make it work?

If your update animation blueprint node fires then that means that it is active and therefore casting to another animBP will fail since you are obviously using the one that is calling the cast to and it is not the other animBP. Whatever value you are trying to get from the other animBP should be set or stored somewhere else that would allow for it to be read from this animBP.

So do you mean I should make a normal blueprint, then make that call the variable from the first animation blueprint, then get the second animation blueprint to call it from that?

What I mean is if the owning pawn is using the animBP and the animBP is casting to another animBP the cast will always fail because the current one cant possibly be the other one…if the owning pawn is using animBP1 then animBP1 cannot be cast to animBP2 because it is an animBP1 animation blueprint…is that making sense?

Also no, it doesn’t have to be another blueprint made to call the variable you could use the player controller to store variable data, the playerBP itself, as well as a game state or you could pass the information through an interface etc, lots of ways but you cant cast from one animBP to another and expect it to return because the animBP that is calling the cast is inherently not the other animBP.

So I’m going to call the variable from animation blueprint 1 to my player character blueprint. (animation blueprint 1 is used by the player character). Then I’m going to call it from the player character blueprint to the animation blueprint 2. (which is unrelated to the others)

So what do I put instead of ‘get anim instance’ and ‘get owning component’ for each of these if I use what is in the picture above?

Does anybody else have a solution to this? I’m so close to getting something to work, but I have no idea what to do for this ‘cast to’!

You haven’t plugged anything into the IsValid node for one.

Also are you doing anything with that variable at the end? Maybe try printing it’s value after the cast to node to see if it’s working. I see that the variable at the end is set to be replicated, are you making a multiplayer game? What blueprint are you trying to do this on? Are there any error messages? We need more details.

I have already given you a lot of those details. Like I said, ‘get anim instance’ is plugged into ‘is valid’ in the real blueprint. I’m trying to get a variable from an animation blueprint. That replicated variable at the end is on somebody else’s blueprint that showed this example to me. I am printing the value at the end, but it won’t print because the cast is failing.

Unless you know what I should have instead of ‘get owning component’ and ‘get anim instance’ if I want to use two of these to call a variable from an animation blueprint onto a character blueprint, then call that onto another animation blueprint, then don’t answer my question yet please!

Don’t worry, I managed to figure it out eventually.