Is there a way to activate an object inside another objects script by using SetActive?
I have posted questions about this before but have got replies saying the question wasn’t very clear so this is as clear as I can make it.
Thanks in advance!
Is there a way to activate an object inside another objects script by using SetActive?
I have posted questions about this before but have got replies saying the question wasn’t very clear so this is as clear as I can make it.
Thanks in advance!
You will receive an error if you try to set an object to active in your scene using GameObject.Find, as it will not be found(because it is inactive). You need to set up a reference to the object you wish to change in your script. Declare this at the top of your script:
public GameObject target;
You can then assign your target to this new variable in the inspector. Then all you have to do to enable/disable the object is:
target.SetActive(true);
//or
target.SetActive(false);
hiya, there are many questions on this, you have to devide it into two steps, “access gameobject from other script”
make a variable equals to other object using drag or gameObject.Find or trigger, etc
and then set active
var hand = GameObject.Find("Hand");
hand.... set active
i d recommend following tornado twins worm game tutorial and then becoming familiar with searching clues to a question with different phrases and familiar with reference.