- Home /
Question by
triis4924 · Feb 25, 2019 at 01:01 PM ·
scripting problemgetcomponentfunctionvoid
Call void for one Object
I have two gameObjects with a script named "Planet" and If I collide with one of these Objects I want to call a public void named "UpdateValues" in my Planet script, but it calls the void on both objects and I only want to call the void on the Object I collide with. here is My code:
dockedPlanet = col.gameObject;
planetscript = GameObject.Find(dockedPlanet.name).GetComponent<planet>();
planetscript.UpdateValues();
any Solutions?
Comment
Best Answer
Answer by triis4924 · Feb 25, 2019 at 02:47 PM
I was using Static variables and because of that, the scripts share the same variable. And because of that, it didn't work