[solved] Get variable of Character BP from an AnimBP: cast works, variable not private, but not showing

Hello all,
I’ve read other threads on similar issues, watched videos and everything, and tried a bunch of different things to no avail. I’m fairly new to using UE5.

I’m working on my main character blueprint (currently named BP_AverageJoe, from parent class BP_Third_Person_Character). I obviously set some variables in this character BP.

Now in my Animation blueprint, named ABP_MainChar derived from Anim_Instance class, I want to access those.

Inside the AnimBP, I cast to BP_AverageJoe to set the Character object variable, from which I plan to get the variables I need to drive the animations.

Cast seems to work fine, as the debug print node shows when the AnimBP is compiled:

Yet, I can’t access any variable from the Character BP in the Anim BP.

I’m sure I’m an idiot and I just missed some trivial thing, but I spent the afternoon looking everywhere, so I figured I’d give the seasoned devs here an opportunity to show me how much of a beginner I really am :slight_smile:

Hi RaHaNGS,

Is your “Character” variable in your AnimBlueprint set as a “BP_Average_Joe”?

It needs that definition type to access it’s variables.

2 Likes

That was it, thank you :slight_smile: - changing the character variable to BP_AverageJoe object and casting to BP_AverageJoe now gives me the references I wanted.

Complementary question: it was originally setup as a Character object, not a BP_AverageJoe one (which was the way it was in the ThirdPerson Blueprint I started with); that’s why there is still a Cast to Character node in the AnimBP initialization part, that I used to use up until now without any issues.

If I was to assign to my new variables the “Character” category in BP_AverageJoe, would I be able to access them with the original Cast to Character?

1 Like

You’re welcome!

Yes you can cast between BP_AverageJoe and Character as much as you want - it doesn’t matter which they are stored as, you will always be able to cast it back to BP_AverageJoe - as long as it was “Spawned/Created” as BP_AverageJoe you’re good to go…

I meant, if it had stayed set up as the default ThirdPerson BluePrint (i.e. Get Owning Actor → Cast to Character → Set variable “Character”, with that variable of the type Character and not BP_AverageJoe), I couldn’t access the variables I created on the BP_AverageJoe blueprint…

That’s correct - “Character” doesn’t know anything about “BP_AverageJoe” - but “BP_AverageJoe” knows about “Character” as it is a SubClass.

Makes total sense. First time I actually use visual programming, and for some reason I find it more confusing that actually writing code… since I don’t know exactly what the nodes do, what they inherit from, etc. But I guess that’s just a bit of getting used to and more reading the docs of those nodes ;p

Anyways, thanks a lot for your help, patience, and additional details!

1 Like

This topic has been moved from International to Programming & Scripting: Blueprint.

When posting, please review the categories to ensure your topic is posted in the most relevant space. This thread has been moved to help other devs with a similar question.

Thanks and happy developing! :slight_smile: