Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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;
	}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: CS0101 
Csharp :: getmousebuttondown unity 
Csharp :: c# iterate enum 
Csharp :: c# linq select only unique values from list 
Csharp :: route attribute controller with parameter asp.net core 
Csharp :: rock paper scissors c# 
Csharp :: item switch unity 
Csharp :: array sort c# 
Csharp :: c# break from foreach method 
Csharp :: check if file exist c# 
Csharp :: c# parse string to xml 
Csharp :: unity find object by name 
Csharp :: get x and y of mouse uinty 
Csharp :: datatable linq where clause c# 
Csharp :: unity interfaces 
Csharp :: calculate how much memory an object take c# 
Csharp :: unity 3d movement script 
Csharp :: difference between boxing and unboxing in java 
Csharp :: c# remove char from string 
Csharp :: .net core partial view with model 
Csharp :: c# datetime for filename 
Csharp :: bundle.config in mvc is missing 
Csharp :: asp.net core api Self referencing loop detected for property 
Csharp :: verify if number c# 
Csharp :: make variables in c# 
Csharp :: how to make a string in c# 
Csharp :: unity onclick object 
Csharp :: custom click event wpf button 
Csharp :: how to iterate between hour range in c# 
Csharp :: c# scroll to bottom of datagridview vb.net 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =