- Home /
SetActiveRecursivity Problem
Ok so I have this sheet of paper/note which the player is supposed to take.
The ideea is the following : when the player takes the paper a monster should appear in his back, scaring the people. I thought about doing this using the SetactiveRecursivity function.
To activate Monster GameObject I use the following sequence, a script attached to a empty gameObject. :
if( !GameObject.FindWithTag("File3")){
sk.SetActiveRecursively(false); //Other gameObject
skWithAI.SetActiveRecursively(true);
}
The problem is that when the object is activated the monster is gliding/sliding towards the player instead of playing the run/walk animation.
have observed that if I deactivate the note object(while play is on) the monster appears and glides towards me, like I said before. If I activate it again the monster scripts and animations begin to work properly, I mean he starts running instead of gliding.
The monster is childrened like Monster(EmptyGameObject) -> Zombie -> Meshes in Subdivisions (eg : left clavicule -> left arm and so on.)
I think the problem is not te SetActiveRecursivity, but your Start(), Update() or Awake() methods for any behavior attached to skWithAI (or any of its childrens). If the object is sliding, could be something related to gravity of a rigidbody or a collider. Could you describe a bit more about the code for your Activated object (and children)?. Have you tried to activate this object from the designer since your scene starts?, does it have the same sliding behavior?
I have modified the post, I have added more detailes.
No, the enemy doesn't have a rigidbody but it has the ch. controller collider.
Answer by mstevenson · Nov 17, 2012 at 08:33 AM
I'd suggest performing any setup for the monster, such as explicitly playing the run animation, in the OnEnable method. This will allow you to be certain that the monster is reset to a known state each time it appears.