- Home /
how to activate a public void from another script
how to active an:
public void blabla()
from other script?
Answer by legion_44 · Sep 07, 2013 at 03:37 PM
In C#
public Transform t; //Transform that script is attached to
t.GetComponent<SCRIPT_NAME>().blabla(); //Invoke method
//or you can use
GameObject.Find("GAME_OBJECT_WITH_SCRIPT_NAME").GetComponent<SCRIPT_NAME>().blabla(); //Finding via name
//Finding via tag
GameObject.FindWithTag("GAME_OBJECT_WITH_SCRIPT_TAG").GetComponent<SCRIPT_NAME>().blabla();
Hope that helps
Paul
i get that error: the member 'WeaponBase.aimOut' cannot be used as method or delegate
i want to active a public void from a base script
I seriously recommend looking up the basics of C# program$$anonymous$$g - this is literally one of the simplest things in the language.
i know the basics, and i discovered that the void i'm trying to activate was private
The very fact that you're calling it a "void" and not a method shows me that you really don't know the basics. Plus, if you knew the basics, you'd know how to do this.
So somebody asks an apparently simple question on here, and ins$$anonymous$$d of replying with the apparently simple answer, you say "I recommend you look up the answer. If you looked up the answer you would know the answer." Great. So helpful. Exactly what this forum is for.
Your answer
