Translate Like chaiwise
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..
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..
Code:
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;
if(y1<=5.6f)
{
No1_currpos.y=y1;
No1.transform.position=No1_currpos;
}
else if(y1>5.6f)
{
y1=-8.5f;
}
if(y2<=5.6f)
{
No2_currpos.y=y2;
No2.transform.position =No2_currpos;
}
else if(y2>5.6f)
{
y2=-8.5f;
}
if(y3<=5.6f)
{
No3_currpos.y=y3;
No3.transform.position =No3_currpos;
}
else if(y3>5.6f)
{
y3=-8.5f;
}
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");
}
}
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Translate mouse coordinates to world coordinates | nalenb | 4 | 4,905 |
Mar 21, 2006 11:59 PM Last Post: glMatt |
|

