Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

mouselook script unity

public float lookSpeed = 3;
private Vector2 rotation = Vector2.zero;
public void Look() // Look rotation (UP down is Camera) (Left right is Transform rotation)
    {
        rotation.y += Input.GetAxis("Mouse X");
        rotation.x += -Input.GetAxis("Mouse Y");
        rotation.x = Mathf.Clamp(rotation.x, -15f, 15f);
        transform.eulerAngles = new Vector2(0,rotation.y) * lookSpeed;
        Camera.main.transform.localRotation = Quaternion.Euler(rotation.x * lookSpeed, 0, 0);
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to detect when a player move in unity 
Csharp :: remove a specific line in richtextbox c# 
Csharp :: c# string capital first letter extension method 
Csharp :: c# get first 5 characters of string 
Csharp :: C# list to string one line 
Csharp :: headless chromedriver C# 
Csharp :: percentage in c# 
Csharp :: difference between namespace and assembly in c# 
Csharp :: There is already a virtual axis named Horizontal registered. unity 
Csharp :: c# how to convert string to int 
Csharp :: unity mouse disapear 
Csharp :: set mouse over colors for button wpf 
Csharp :: on collision 2d unity 
Csharp :: Unity Scene Load by Name 
Csharp :: how to convert a bitmap to a base64 string c# xamarin universal 
Csharp :: hide game obj oncollisionenter 
Csharp :: c# string to uri 
Csharp :: c# read all text from a file 
Csharp :: socket would block error c# 
Csharp :: add leading zeroes in c# 
Csharp :: c# declare inline string array 
Csharp :: blank background for button wpf 
Csharp :: c# close 1 form open another form 
Csharp :: c# ascii to char 
Csharp :: how to center text in console application 
Csharp :: coroutine not eaffected by time.timescale unity 
Csharp :: convert string to short c# 
Csharp :: c# int positive only 
Csharp :: dictionary to string c# 
Csharp :: loop through all enum values in C# 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =