SharedVariable inheritance

AraragiAriel

New member
Hey! Is it possible to have a SharedVariable inherit from another SharedVariable?

1677109195067.png
1677109207253.png

I have these two classes from which I created their respectives SharedVariables

1677109276626.png

1677109288089.png

But doing it this way doesn't make it so that SharedEnemyMelee automatically inherits from SharedEnemy. Or at least I'm not able to use SharedEnemyMelee in a task which needs a SharedEnemy, which would be possible outside of SharedVariables.

1677109556337.png

I also tried to inherit directly from SharedEnemy, but this way, even though it compiles, I can longer access the Value on the SharedEnemyMelee.

Is there a proper way to set up the inheritance?
Thanks!
 
In this situation you can use SharedEnemy and then cast the value to EnemyMelee, but I do agree that it would be better to be able to use a SharedEnemyMelee directly. I believe that it's just the editor preventing the link and from a code perspective it would work without an issue. I'll look at this for the next update.
 
I see. But then how should I do the casting?

1677161996051.png

I tried it like this, but it returns this error

1677162037769.png

Should I edit something in the SharedEnemy script to account for the casting?

Thanks for the reply!
 
Top