I came across this thing while I was improving my animation blueprint and I’m wondering if it is an intentional feature and safe to use. I didn’t know what search terms to use to find anything out about it.
Basically I wanted to get a reference of the parent blueprint (character) into it’s child blueprint’s animation blueprint. I wasn’t sure on how to do it, so I started experimenting. I figured out this way to save the “self” value of the parent blueprint and save it straight to the animation blueprint with an event that is called inside the child.
The picture is from inside the master character blueprint (parent class):
Here is where it gets funky for me… When I print out the reference of the parent that has been saved inside the variable, it gives the child blueprint’s reference instead! So basically the master character reference (in picture) has a reference to the child character 1 or child character 2 in it. What is going on here?
Im not sure why you want to get an instance of itself, if your character is a child the child will have its own reference to its own anim instance. child inherits everything from the parent. so your literally getting a reference to itself. Child character A is going to have a Child AnimBP A
I have been using Try Get Pawn Owner but I want to use the same animation blueprint in both child characters. I had this thing where it cast to both of the child characters to figure out which one the animation blueprint belong to and then it took the necessary variables and stuff from that child.
However, if the way I showed in my post is a safe and valid way of doing it, it would simplify the animation blueprint a lot since I wouldn’t have to cast to both child blueprints and figure out which child it is. That’s why I would like to do it with the method I asked about.
I know the child inherits everything from it’s parent, but I want to use the same animation blueprint in both child blueprints, which means I need to figure out which child it is, which child to get the variables and stuff from, and all this extra logic.
If you’re trying to treat the child classes as the parent class, then in the animation blueprint, just cast to the parent class; that will treat the child classes as the parent (ex. the default ThirdPersonCharacter can be treated as a Character, Pawn, and Actor because it is a child of all of those classes). This does exactly what you’re trying to do in your first post.
Unless you need something that only exists in a child class but not the parent, you don’t need to cast to the child.
-Had to make a new post because editing is apparently broke rn.-
You can actually fix what you have in your first post by casting “self” to the parent class. You will get a note under the node that says that you don’t need to do this since the child inherits from the parent, but you can ignore that.
Ahh, I don’t know why I hadn’t realized this before! So it is a reference to the parent class even though it says the name of the child blueprint when you print out the value from the cast?
So I should be able to cast to the parent blueprint with Try Get Pawn Owner and I can store it in a single variable whether it is any of the child classes? This is safe and reliable?
Yeah, the name that prints out will still be “ChildClass…” because that is what class it actually is. But because it inherits from the parent class, it can also be considered and treated as the parent, which means you’re able to set it in a variable of the parent class.
Yeah, the printed out value just saying the child class’ name really confused me. But okay, it works now! (Apart from the Property Access nodes which I’m pretty sure are fundamentally broken lol, but that’s a different topic…)