- Home /
Top down camera for object moving on sphere
Hello, do anybody know how to create rotation of top down camera, that should follow object, which is moving on sphere(planet)
Answer by FrZn · Oct 22, 2018 at 11:11 PM
If you just want it to be straight above the object without any horizontal offset, you could do something like this:
float verticalOffset = 10f;
Transform player;
Transform planet;
void LateUpdate()
{
Vector3 direction = (player.position - planet.position).normalized;
Vector3 targetPosition = player.position + direction * verticalOffset;
transform.position = targetPosition;
transform.LookAt(player.position);
}
If you want the camera to be offset so it is behind the player, you would have to take the players moving direction into account when calculating the new camera position.
Thanx, it works quite properly, but how to fix quick camera rotation around its Y axis, while crossing top and bottom of planet?
Your answer
Follow this Question
Related Questions
Rotate player to screen pos 0 Answers
Reset player movement axes after camera rotation 1 Answer
How to make 90 degree snapping camera, center on object? 0 Answers
Camera.WorldToScreenPoint Equivalent 1 Answer
Rotate Character Controller Camera 0 Answers