C# How to Rotate My Character with Mouse Movement?

Hello! Im making a bird view game and I want to make my character rotate with mouse moves on y axis and 360 degree. Can someone help me please.

Thanks, atkn007

You want that you character looks at the mouse position?

  1. Check the position on which the mouse points to (Physics.Raycast).
  2. Calculate the angle between your character and the given position (Mathf.Atan2 or Quaternion.LookAt)
    3a. Set the angle as the value of your eulerAngles.y (copy eulerAngles to temp variable, change Y and set the temp variable to eulerAngles)
    3b. Set the generated Quaternion to your rotation variable

I just use gameObject.transform.Rotate(0, Input.GetAxis(“Mouse X”) * sensitivityX, 0);
To rotate a turret along X Axis with mouse…

@Marrrk Yes, I want to make my character look at mouse position.Thanks for the info.

@image28 Uhhm, I tried it but didnt work. Thanks for the info.