I want to rotate my Player with my mouse and let him look in the direction my cursor is located.
Sadly I am pretty New to Unity and have no clue how to even start…
I am using C# and no charaktercontroller… I Hope you can help me
Thanks
Sc4v4nger
Have a look at Quaternion.LookRotation():
Out of the top of my head this should be pretty close to what you need:
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour {
public Transform target;
void Update() {
Vector3 mousePosition = Input.mousePosition;
Vector3 targetPosition = Camera.ScreenToWorldPoint(mousePos);
Vector3 relativePos = targetPosition - transform.position;
Quaternion rotation = Quaternion.LookRotation(relativePos);
transform.rotation = rotation;
}
}