All Questions

Community

M
Mcfrosty1111

Variable change in child class affecting parent class

I was playing around in a test scene and noticed if i set a variable in the parent class and then changed it in the child class, anytime later i called upon the parent class the variable was affected by the child script??? Is there a clear explanation of how these work together?

  • Nathan Lovato replied

    The child's code can't affect the parent script. It's probably something else that happened.

    The way it works is that the child script extends the parent. That is to say, it has the parent's code + its code. The parent doesn't load or know anything about the child's script though.

    If you can share your entire scripts and the unexpected thing that happened, we can help you shed some light on why that happened.