- Home /
 
 
               Question by 
               Punk4tt4ck · Dec 18, 2016 at 11:23 AM · 
                positionscripting beginnertranslateproblem during runtime  
              
 
              Child Transform Problem
I got a parent under which are 4 childs. I target them and translate them on collision. But the translation is only done on 2 childs which are listed child 2 and 3 and on the child 0 and 1 the x position is adding but nothing happens. They just stay on the place.
     // Use this for initialization
     void Start () 
     {
         movable_obstacle = false;
         obstacle_trans = GetComponentsInChildren<Transform>();
 
     }
     
     // Update is called once per frame
     void Update () 
     {
         if(movable_obstacle)
         {
             //print ("It is movable");
 
             foreach (Transform obt in obstacle_trans) 
             {
                 
                 obt.Translate (Time.deltaTime * 1 ,0,0);
             }
         }
     }
 
     void OnTriggerEnter(Collider coll)
     {
         switch (gameObject.tag) {
 
         case "Cube_Obstacle_Circle":
             print ("Cube_Obstacle_Circle");
 
             if (coll.tag == "P_Circle") {
                 movable_obstacle = true;
             } 
             else 
             {
                 print ("GAMEOVER");
                 game_over = false;
             }
 
             break;
         case "Cube_Obstacle_Square":
             print ("Cube_Obstacle_Square");
 
             if (coll.tag == "P_Square") {
                 movable_obstacle = true;
             } 
             else 
             {
                 print ("GAMEOVER");
                 game_over = false;
             }
 
             break;
         case "Cube_Obstacle_Triangle":
             print ("Cube_Obstacle_Triangle");
 
             if (coll.tag == "P_Triangle") {
                 movable_obstacle = true;
             } 
             else 
             {
                 print ("GAMEOVER");
                 game_over = false;
             }
 
             break;
         }
     }
 
              
               Comment
              
 
               
              Your answer