I let my player rotate. He is rotating when i move my mouse but he don’t is fast enough to follow my mouse every time. My mouse is on the up and my player is looking right?
Anyone?
Show your script so we can actually help. Who knows what you did.
O sorry that was really dumb from me. I tought i already did that but here is the code:
using UnityEngine;
using System.Collections;
public class RotateToMouse : MonoBehaviour {
void Update () {
//rotation
Vector3 mousePos = Input.mousePosition;
mousePos.z = 5.23f;
Vector3 objectPos = Camera.main.WorldToScreenPoint (transform.position);
mousePos.x = mousePos.x - objectPos.x;
mousePos.y = mousePos.y - objectPos.y;
float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
}
}
I dont know what is wrong in your scene, but script works just great. Maybe its the way your sprite is set up.
Or even your scene. How is the ground rotated in your scene?
In my example, its vertical
Works as expected
Do you have Skype or something? Its hard to let it see here.
If you can pm me a package