Hi, im making game mechanically similar to nuclear throne. I have player with weapon that sticks to his centre and Iwant that weapon to rotate around by player, but at some distance from him. This is code of my weapon
void LateUpdate () {
this.transform.position = new Vector3 (player.transform.position.x, player.transform.position.y, -1);
Vector2 dir = Input.mousePosition - Camera.main.WorldToScreenPoint (transform.position);
float angle = Mathf.Atan2 (dir.y, dir.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis (angle, Vector3.forward);
}
I’m bad at english so i made drawing to help you understand me.
circle - player, red gun - weapon, green point - the center of sprite, the red circle is how weapon rotates. I want something like the right picture. There is code that