edited February 2015 in ORK Scripting
I use a script add some components to combatant when it spawn, But when the combatant enter to the second scene, These added component by my script are missed.
How do I have right time to call my script when "scene change" event happen.



void Awake(){
CharacterController c = gameObject.GetComponent<CharacterController>();
if (c == null) {
c = gameObject.AddComponent<CharacterController>();

}
c.center = new Vector3(0, 1, 0);

//---- I add other component to combatant there,
//---- I may add this in Update(), But it seem that the CharacterController just can add on Awake() method,

}



I want do some things by script when a profab spawn(such as ability, item ), So I don't want add these components to profab static, Because I hope keep these prefabs simple.


By the way, I follow the "Game tutorial: 50. Adding a 2nd player group member", When enter the "2 Field" The blue Pants isn't on the ground. I want call a function to let it stand on the ground after "scene change" event happen.

Or may You have good solution for this , I am sorry for I don't catch it now.

I use a script to add these component, It seem work(combatant, ability, weapon) , For the play combatant go to the second scene, I add these again.
Post edited by ZhaoYu on
  • Did you add your script to the combatant's prefab? The Awake function should be called each time the component is added or the game object is spawned.

    You can add a Spawn On Ground component to the prefab of Blue Pants to spawn him on the ground.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.