Search Unity

dettach children does not work.. ...try to null parent...

Discussion in 'Scripting' started by spaceMan-2.5, May 17, 2011.

  1. spaceMan-2.5

    spaceMan-2.5

    Joined:
    Oct 21, 2009
    Posts:
    710
    Code (csharp):
    1.  
    2. private var henry;
    3.  
    4. function Start () {
    5. henry = GameObject.Find("henry");
    6. }
    7.  
    8. function OnTriggerEnter (other : Collider) {
    9. henry.transform.parent = transform;
    10. }
    11.  
    12. function OnTriggerExit (other : Collider) {
    13. Debug.Log("glugluglu");
    14. henry.transform.parent = null;
    15. }
    16.  
    henry.transform.parent = null; is not doing anything... how do you detach children from its parent?

    Mike
     
    Last edited: May 17, 2011
  2. spaceMan-2.5

    spaceMan-2.5

    Joined:
    Oct 21, 2009
    Posts:
    710
    i haven´t saw DetachChildren() function.. i will try with that..
     
  3. spaceMan-2.5

    spaceMan-2.5

    Joined:
    Oct 21, 2009
    Posts:
    710
    oops, does not work.. strangely the OnTriggerExit does not works, but when i comment the "transform.DetachChildren()" or "henry.transform.parent" works again....

    what i want to do is a moving ramp... player jumps into this ramp, but to avoid player falls when ramp is moving, i must to make child of ramp so player moves with ramp... some trick?

    thanks.
     
  4. spaceMan-2.5

    spaceMan-2.5

    Joined:
    Oct 21, 2009
    Posts:
    710
    solved...!

    i don´t understood why.. but i changed OnTriggerEnter to OnTriggerStay and works fine... weird...