I realize this question has been asked and answered a lot, however everything I can find either uses an outdated version of unity and the scripts don’t work, the scripts use javaScript (I use c#), or it just plain doesn’t work for what I want.
I have a green oval sprite with a slice out of it and a smaller green oval sprite without anything missing (see Fig. 1). I want the missing piece of the larger oval to always face the smaller oval no matter where the smaller oval is. (This is a 2d game and nothing should move along the “z” axis)
(Fig. 1)
This is the script I currently have:
public Transform player;
Vector3 target;
void Update()
{
target = new Vector3(player.position.x, player.position.y, this.transform.position.z);
transform.LookAt(target);
}
However this does not work. It always rotates the larger oval 90 degrees along the “y” axis so the larger oval faces the smaller one like this:
I have used just about everything I can find and everything either doesn’t work or ends in the same result.
Please explain to me why this is happening and how I can fix this.
thanks for your help in advance.