Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

first person mouse look 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 :: Reverse Coding Challenge 1 
Csharp :: c# string to bool 
Csharp :: c# code to read txt file line by line and split 
Csharp :: Kill System Process in C# 
Csharp :: c# string console readline array 
Csharp :: how to type to console in unity 
Csharp :: type or namespace text could not be found unity 
Csharp :: if c# 
Csharp :: c# api bypass ssl certificate 
Csharp :: unity detect a touch on ui element 
Csharp :: run file windows forms 
Csharp :: httpget query parameters c# 
Csharp :: unity respawn 
Csharp :: how to add to a list in c# 
Csharp :: c# override gethashcode 
Csharp :: regex for accepting a file name c# 
Csharp :: c# recursion formula for the factorial 
Csharp :: linq datatable 
Csharp :: Commenting on C# 
Csharp :: vb.net check if datatable has rows 
Csharp :: c# add list to list 
Csharp :: c# get string in parentheses 
Csharp :: max index array c# 
Csharp :: onmousedown() not working unity 
Csharp :: How to use the protected keyword in C# 
Csharp :: C# System.nanoTime 
Csharp :: string trin c# 
Csharp :: c# open access database mdb 
Csharp :: c# Remove String In C# 
Csharp :: get script directory c# 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =