Inheritance Variables

Is there a way to use/change variables that are in the parent ActorComponent from the child AddComponent. I have a Jump Component that has the DoubleJump component as it’s child, but it seems that when the variable changes to true in the Jump, it still remains false in the double jump. (First image isjump, second is double jump)

Hello,

Can you show me more information please?

1 - What is your setup in the actor hierarchy?
2 - How do you call Jump? Are you sure it is really called?
3 - What is the parent class of your Jump Component?
4 - What is the parent class of your Double Jump Component?

I knew I left some stuff out. The setup is just two components for now. The Jump Component is a component attached to the player character blueprintas well as the DoubleJump. Then jump is the parent of doublejump. Jump Component doesn’t have a parent.The variable CouldDoubleJump is within the JumpComponent.

Image is the jump componenet being called from character BP

This is the double jump being called from the character bp as well

Ok, if I understand well, you need to remove the BPC_Jump from your player and then call the ‘‘Jump’’ function on the BPC_DoubleJump.

If BPC_DoubleJump is really a child of BPC_Jump, it should have the ‘‘Jump’’ function too.

In the way you have it setup right now, you have 2 component instances from 2 different classes.
By calling ‘‘Jump’’ on BPC_Jump, it sets the ‘‘CanDoubleJump’’ value inside this instance, but does not affect BPC_DoubleJump
Then, you are checking the ‘‘CanDoubleJump’’ value on BPC_DoubleJump when calling ‘‘DoubleJump’’. Value that never changed

Sorry if my explanations are difficult to understand, I did not find an simplier way to explain this.

I think I understand. Sorry if this got a bit complicated, it was one of the very few ways I could manage moves, by using components. See, I wanted there to be a hierarchy of components in such a way that the player will gain them down the line in the game i.e. Level one-> Jump, Level 2-> Double Jump, Level 3-> Ground Pound, Level 4-> Glide. Each of these component moves needs to “know” each other or inherit from each other somehow to turn them on and off depending on which one is being used.

From what you explained to me, if I had all four of the abilities above implemented, then the last ability, the Glide, would be the parent, then ->Ground Pound->DoubleJump->Jump. So If I wanted to jump, I’d used the Glide component. Right?? But wouldn’t that cause a bunch of annoying cast??

To answer your question, no. Not if your reference is the last child of the hierarchy (assuming they are all in a linear inheritance).
e.g. You have create a custom blueprint actor class. When you place this actor into the world, you don’t need to cast it into Actor before calling the function GetActorLocation() because it is inside its parent.

And, in my head I had something more like: Jump -> DoubleJump -> GroundPound -> Glide
And you are using Glide (Because it is the last child)

But, that said, I’m not sure it is the best strategy for this. (I’m really not sure that my suggestion is the best because I only thought about it for 5 minutes, but here it is.)
If you want to separate all your actions into multiple components, I think it is probably better to only use inheritance on components that uses the same functionnalities (like Jump and DoubleJump).
And have an higher level manager that will decide if the current character can call the DoubleJump component instead of the Jump one.
In shot, not saving the ‘‘CanDoubleJump’’ variable inside the component, but inside the manager that make the decision of which component to execute.

And instead of adding components based on the progression, you can simply add all of them to your actor and then simply ‘‘Activate’’ them in the manager when unlocked.
Or something like that.

Or maybe simply have 1 component that contains all the possible actions, but I’m really not sure about this one ^^’

I was thinking the same thing with the whole concept of adding all the components then turning them on and off…the whole manager thing will take some thinking, especially if I want it to look clean and understandable to add and remove abilities. As far as I know right now, Jump and Double Jump are the only abilities that’s similar, might as well suck it up and put them into the same component for simplicity sake.

I’ll move some things around and report back my best findings.

Have fun ^^