SO im trying to have a target follow a mouse around my player
Similar to this:
i even tried to copy his code, my issue is i cannot get the target to rotate around the player, its sorta stuck rotating somewhere else and then when i move my player the target starts to move across the screen really fast.
my code:
private float Radius = .24f;
private float angle;
private Vector3 v3pos;
void FixedUpdate () {
GameObject player = GameObject.Find("Player1");
v3pos = Input.mousePosition;
v3pos.z = (player.transform.position.z - Camera.main.transform.position.z);
v3pos = Camera.main.ScreenToWorldPoint(v3pos);
v3pos = v3pos - player.transform.position;
angle = Mathf.Atan2(v3pos.y, v3pos.x) * Mathf.Rad2Deg;
if (angle < 0.0f) angle += 360.0f;
transform.localEulerAngles = new Vector3(0,0, angle);
float xpos = Mathf.Cos(Mathf.Deg2Rad * angle) * Radius;
float ypos = Mathf.Sin(Mathf.Deg2Rad * angle) * Radius;
transform.localPosition = new Vector3(player.transform.position.x + xpos * 2, player.transform.position.y + ypos * 2, 0);
}