- Home /
Question by
Smart_GamingYT · Jan 12 at 01:41 AM ·
destroyobjectsnoobactivateactivation
How to activate an object when another object deactivates?
So I have the following code:
public class Appear : MonoBehaviour
{
public GameObject objectOne;
public GameObject objectTwo;
void Update()
{
if (objectOne.SetActive(false))
{
objectTwo.SetActive(true);
}
}
}
It doesn't work and I don't know why. All I want to do is activate 'objectTwo' when 'objectOne' is deactivated. So basically in the game, if an object gets de activated or destroyed, then object two will appear.
Comment
Answer by menstroke · Jan 12 at 07:45 AM
Make sure Appear.cs attach to other game object that not objectOne or objectTwo. That's all but this can be optimize for better performance later.
Your answer
Follow this Question
Related Questions
Destroy is not working with moving objects 1 Answer
How to implement animation on trigger/without? 1 Answer
Right way of controlling objects in Scene? 1 Answer
Unity License Activation 2 Answers
Destroying objects one at a time 1 Answer