- Home /
Question by
Erven · Jun 22, 2016 at 09:11 PM ·
lookatrotatearoundorbitlookattargetindicator
Indicator rotating around player
I'm trying to make an indicator that rotates around the player and points an other object in 2D game. So far I have made orbiting around the player, but can't figure out how to make it point the other object. The picture shows, what I want to make. The code:
public Transform player;
public Transform target;
void Orbit()
{
transform.position = player.position + (transform.position - player.position).normalized * orbitDistance;
transform.RotateAround(player.position, Vector3.forward, 0);
}
orbit.png
(1.7 kB)
Comment
Answer by jdean300 · Jun 23, 2016 at 06:37 AM
You should just be able to do:
transform.LookAt(target)
https://docs.unity3d.com/ScriptReference/Transform.LookAt.html
I know that, but how to combine it with orbiting around player?