- Home /
Top-down 2D: How to fly an object to a point, turning smoothly.
I've got a little plane that is always moving forward. It can turn slowly as well. I'd like it to try and fly towards a given point. Naturally when it reaches the point it would fly over and past it, and then have to turn back around to fly towards it again.
I've gotten as far as turning the plane slowly towards the point. But when the plane reaches the point the turning speed goes haywire and the plane spazzes out. Can you tell me what I'm missing in my turning script and how to solve it?
Vector3 dir = anchor - transform.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90;
angle = angle * (Time.deltaTime + turningSpeed);
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
Comment
Your answer
Follow this Question
Related Questions
2D character movement is jittery (top-down) 1 Answer
Creating a wrap around bullet effect like Asteroids. 1 Answer
2D Topdown movement without sliding 2 Answers
2D Top Down Game, 2D or 3D defaults? 1 Answer
2D Topdown Shooter Enemy Knockback 0 Answers