Answers for "how to make something look at the cursor in unity"

C#
0

how to look around with mouse in unity

public class CameraController : MonoBehaviour //The script should be on the camera or on the player if it is a sphere
{
	
  	Vector2 rotation = Vector2.zero;
	public float speed = 3; //the sensibility

	void Update () 
    {
		rotation.y += Input.GetAxis("Mouse X");
		rotation.x += -Input.GetAxis("Mouse Y");
		transform.eulerAngles = (Vector2)rotation * speed;
	}
}
Posted by: Guest on May-03-2021
0

unity set cursor position

//C#
    using System.Runtime.InteropServices;
    [DllImport("user32.dll")]
    static extern bool SetCursorPos(int X, int Y);
    int xPos = 30, yPos = 1000;   
    SetCursorPos(xPos,yPos);//Call this when you want to set the mouse position
Posted by: Guest on March-22-2021

Code answers related to "how to make something look at the cursor in unity"

C# Answers by Framework

Browse Popular Code Answers by Language