- Home /
Activate / Deactivate objects onTriggerEnter / Exit
Hi,
I have read a few threads with this topic, but currently I am confused, especially since in Unity 4 setActive() now seems to affect children too.
I want to ask this in a very very basic way.
Suppose I have a gameobject marking a section of my scene. It has children. I want to activate the children only onTriggerEnter. Similarly, I want to deactivate (or even destroy) all children onTriggerExit.
Another thing. Ideally, the script which has onTriggerEnter also would have an awake function which deactivates all children by default. This way, when I enter game mode, everything but the first section is deactivated. awake should run before start, so all children should be deactivated before their start() can run.
Alternatively, if this gets too complicated, I'll probably make many scenes. This breaks the experience a bit though.
Answer by kickasskane2 · Jan 04, 2013 at 09:57 PM
I am having the same problem and I think that you should do the other scene trick. Thats what i'm doing and it came out great!
That's what I went for. It's a lot easier to edit this way and efficient enough (for now).
Answer by Vonni · Jan 05, 2013 at 10:07 AM
You could have seperate scenes and merge them in with:
Application.LoadLevelAdditive (1);
Your answer
Follow this Question
Related Questions
ReActivate object with null movement ?? 2 Answers
How do i activate lose screen 1 Answer
OnTriggerEnter is called anyway 0 Answers