How to use inherited value stored in variable, not the value from the parent?

Hi, recently i found that my decal material for bulletholes was not being found. This didnt make sense at first because I set it in the gun derived class, and the derived class is what is being used. I found out the base variable wasnt set, because i wanted the variable to be able to be set differently for different guns. This made it obvious that it was using the parent’s value of the variable. Is there any way to use what I put in the slot for the child blueprint?

You shouldn’t need to pass the Bullet Hole Decal variable back to the parent if it exists in the parent class. If you set the variable to a different value in the child class, whenever it’s used in the parent class logic it’ll use the appropriate child variable value since generally the child value takes precedence over the parent’s.

@SparkyMcSparks From what I understand, it should be using the child variable if I pass it in. however that is not the case. I think there is a bug, with setting it in a derived class and relying on using that. I just tried setting it manually in begin play and it works fine.

It depends what you’re doing in that parent function “Shoot”, if you’re just using the value directly from the Output connection then it should work, but if you’re using a variable node for Bullet Hole Decal without setting the value from the Output connection, it’ll just be the parent’s value.

Here’s how I would do it since it doesn’t require Blueprint scripting in each child function of passing back and forth values:

  1. In Parent Actor have variables for everything you’d want to be tweakable, in this example Fire Delay, which I set to default 0 seconds.

  1. Then in a Child Actor derived from the Parent, you only have to set variable values and override any component values you wish. I set Fire Delay in this derived Actor to be 2 seconds, so the Print String when I fire a weapon will be delayed by two seconds only in that derived Actor class.

Hopefully this helps minimize the maintenance you’d constantly need to do too for each derived class.