Tuesday, November 3, 2015

unity - How to move a object to a target point like sine wave in 2D world


I want to move my gameobject to move point A to target point B like sine wave, I have used Vector2.Lerp but its just straight line. so far I tried many ways and I managed this


//sine wave
vLastPos = new Vector2(transform.position.x , Mathf.Sin(Time.time)*2f+2f);
transform.position = vLastPos+Vector2.right*Time.deltaTime;


but the problem is its moving the gameobject left to right not to target position. the gameobject shold reach the target position and stop. please help me.




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...