Object moves through the position of another object
Hello,
I have three objects animated by a script, when I press a key of my keyboard the three objects rise on the y axis at the same time, has the same speed. What I would like is that when I press, only object 1 goes up, then when it reaches its limit defined by the "rearPos" (which I define directly in the inspector, on the component of the script) , Object 2 rises in its turn. Then once the latter is mounted to the maximum, object 3 rises. Like a kind of "telescope".
Here is my code for the moment:
 Using UnityEngine;
 Using System.Collections;
 
 Public class MovePos2: MonoBehaviour
 {
 
     Public Transform Bras1;
     Public Transform Bras2;
     Public Transform Bras0;
     Public float speed = 0.0f;
     Public KeyCode KeyFOR;
     Public KeyCode KeyAB;
     Public KeyCode KeyBAK;
     Public Vector3 forwardPos;
     Public Vector3 rearPos;
 
 
     Void Start ()
     {
 
     }
 
 
     Void Update ()
     {
 
         If (Input.GetKey (KeyAB) && Input.GetKey (KeyBAK))
             If (Bras0.transform.localPosition < rearPos)
 
 
             {
                 Bras1.transform.localPosition = Vector3.MoveTowards (Bras1.transform.localPosition, rearPos, speed * 0);
                 Bras2.transform.localPosition = Vector3.MoveTowards (Bras2.transform.localPosition, rearPos, speed * 0);
                 Bras0.transform.localPosition = Vector3.MoveTowards (Bras0.transform.localPosition, rearPos, speed * Time.deltaTime);
 
             }
 
             If (Bras0.transform.localPosition =  rearPos)
             If (Bras1.transform.localPosition < rearPos)
 
             {
                 Bras1.transform.localPosition = Vector3.MoveTowards (Bras1.transform.localPosition, rearPos, speed * Time.deltaTime);
                 Bras2.transform.localPosition = Vector3.MoveTowards (Bras2.transform.localPosition, rearPos, speed * 0);
                 Bras0.transform.localPosition = Vector3.MoveTowards (Bras0.transform.localPosition, rearPos, speed * Time.deltaTime);
 
             }
 
 
             If (Bras0.transform.localPosition =  rearPos)
             If (Bras1.transform.localPosition =  rearPos)
 
             {
                 Bras1.transform.localPosition = Vector3.MoveTowards (Bras1.transform.localPosition, rearPos, speed * Time.deltaTime);
                 Bras2.transform.localPosition = Vector3.MoveTowards (Bras2.transform.localPosition, rearPos, speed * Time.deltaTime);
                 Bras0.transform.localPosition = Vector3.MoveTowards (Bras0.transform.localPosition, rearPos, speed * Time.deltaTime);
 
             }
 
     }
 }
In fact I can not understand how to define a condition using the position of an object. I do not know if what is driving is the use of the "<" or "rearPos"
Your answer
 
 
             Follow this Question
Related Questions
SImple, but how do I check a game object's position in an If statement? 1 Answer
Prefab 2d interaction with 3d prefab 0 Answers
how do i fix the compiler errors on unity 5? i have tried everything there is to try. 0 Answers
Move Character to touched Position 2D (Without RigidBody and Animated Movement) 1 Answer
input.getaxis returning -1 by default 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                