iDevGames Forums
Translate Like chaiwise - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Translate Like chaiwise (/thread-10467.html)

Translate Like chaiwise - 12passion - Dec 11, 2012 12:27 AM

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");