Translate Like chaiwise

Posts: 1
Joined: 2012.12
Post: #1
Hello All;
i m trying to move object in y direction like chainwise. i keep two limit upper limit = 5.6f and lower limit=-8.5f;and object move in between two limit like chaiwise. it works when speed is slow but when i increased speed it become overlapped. so can u suggest so that when i increase speed space difference between two object should always same not overlapped..

public GameObject No1;
    public GameObject No2;
    public GameObject No3;

    Vector3 No1_currpos;
    Vector3 No2_currpos;
    Vector3 No3_currpos;
    float y1;
    float y2;
    float y3;
       float speed;
    // Use this for initialization
    void Start () {
    No1_currpos = new Vector3(5.6f,y1,0);
    No2_currpos = new Vector3(5.6f,y2,0);
    No3_currpos = new Vector3(5.6f,y3,0);
        y1 =3f;y2=0.6f;y3=-1.8f;
    // Update is called once per frame
    void Update () {
     y1 +=Time.deltaTime*speed;
     y2 +=Time.deltaTime*speed;
     y3 +=Time.deltaTime*speed;
        else if(y1>5.6f)
            No2.transform.position =No2_currpos;
        else if(y2>5.6f)
            No3.transform.position =No3_currpos;
        else if(y3>5.6f)
        if( No1.transform.position.y>-0.65f&&No1.transform.position.y<1.83f)
          print ("y1");
        if(No2.transform.position.y>-0.65f&&No2.transform.position.y<1.83f  )
             print ("y2");
        if(No3.transform.position.y>-0.65f&&No3.transform.position.y<1.83f  )
             print ("y3");

Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Translate mouse coordinates to world coordinates nalenb 4 13,047 Mar 21, 2006 11:59 PM
Last Post: glMatt