All instances of my gun scene share the same script & methods called in one instance calls in each imstance.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By slightly_seasoned

So, I have a GunTemplate scene & I made an AK-47 & a Glock-17 that inherit from it. They all share the same script & I found a problem; if I call a method on the AK-47 or Glock, like _ready(), it calls the method in both of them. How do I fix this? I tried setting ‘Local to Scene’ on in the shared script, but that didn’t work.

:bust_in_silhouette: Reply From: skysphr

If you want specific code for your inherited scenes, you should extend the parent script. Pseudocode:




extends "res://path/to/"
    ._ready() # Call parent's _ready()

Thank you, I never new I could do this!

slightly_seasoned | 2021-09-25 06:07