I know this question have been asked before and I have checked but cannot get this to work smoothly. I have tested MoveTowards without success.
Can someone nice please help me with this movement scrip so I have constant speed between two locations? …this is my current script with normal Lerp.
IEnumerator SwitchMove (GameObject _parent, string _name, float _x, float _y) {
if (_name != "") {
dummy_GO = GameObject.Find (_name);
} else {
dummy_GO = _parent;
}
float t = 0f;
float speed = 2.5f;
Vector3 endPosition = new Vector3 (_x, _y, 0f);
while (t < 1) {
t += Time.deltaTime / speed;
dummy_GO.transform.position = Vector3.Lerp (dummy_GO.transform.position, endPosition, t);
}
yield return null;
}