I am trying to make a Platformer/Shooter game, and so i want to make my arm follow my mouse so you can aim to where you are shooting. But this is a problem, my arm does move… but not with my mouse exaclty. It’s difficult to explain. I am using this script for the arm rotation…
using UnityEngine;
using System.Collections;
public class ArmRotation : MonoBehaviour {
public int rotationOffset = 90;
// Update is called once per frame
void Update () {
Vector3 difference = Camera.main.ScreenToWorldPoint (Input.mousePosition) - transform.position;
difference.Normalize ();
float RotZ = Mathf.Atan2 (difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler (0f, 0f, RotZ + rotationOffset);
}
}
I’m not sure what to do, please help.
(P.S. I am new to both the C# code, and Unity, so this might be a very easy fix, I don’t know.)