- Home /
activating multiple voids with the same name trough one line
I have multiple objects in my scene who need to act on their bools (so if bool = true then activate code) this code only has to be run once so doing it on "void update" is overkill and will lag my pc. so my idea was to make my own command which is: "public void UpdateBool" but I will have this void command in every object. will one activation of the void command run it in every object? or is there a better way?
Answer by kskjadav007 · Feb 29, 2020 at 12:46 PM
public bool m_activationbool=false;
private void Update()
{
if (m_activationbool==true && this.gameObject.activeSelf==false)
{
this.gameObject.SetActive(true);
}
}
No you just have to access that gameobject's script and turn on bool value and code will run only one time.
Your answer
Follow this Question
Related Questions
Using bools in Update function to run code once not consistent 3 Answers
can't change bool in update function 1 Answer
I'm having problems with bools resetting within a function 0 Answers
Probobly easy fix , int dosnt change issue. 1 Answer
Why does Unity mean with :Cannot implicitly convert type `void' to `bool' ? 3 Answers