This question was
closed Oct 28, 2015 at 12:59 PM by
EnesShahn for the following reason:
The question is answered, right answer was accepted
Coroutine Animation
soo i have 2 cubes and i want to make animation by using Vector3.Lerp so the cube 1 will go Lerp to cube 2 and if both in same place set touched var to true. so i typed this :
IEnumerator PlayAnimation()
{
while(//cube 1.position != cube 2.position//)
{
//lerp Cube1 to cube 2
yield return new waitforseconds(0.01f);
}
//then here i want to check if they are in the same place and if soo then set the touched varible to true
if(//cube 1.position += cube 2.position//)
{
touched = true;
yield break; } }
but the if statement doesnt work ...
Comment
if(cube1.transform.position == cube2.transform.position)
Try that for the if statement.
Best Answer
Answer by EnesShahn · Oct 28, 2015 at 01:20 AM
Solved!!! it was simple this is what i did:
IEnumrator PlayAnimation()
{
while('the twocubes doesnt touch each other')
{
//move the cube 1 to cube 2
//then repeat it until they touch
}
//what i type here will excute after while statment = false
//soo simply
touched = true;
}