Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Unity FPS camera z axis rotating problem

public float xMoveThreshold = 1000.0f;
public float yMoveThreshold = 1000.0f;

public float yMaxLimit = 45.0f;
public float yMinLimit = -45.0f;


float yRotCounter = 0.0f;
float xRotCounter = 0.0f;


// Update is called once per frame
void Update()
{
    xRotCounter += Input.GetAxis("Mouse X") * xMoveThreshold * Time.deltaTime;
    yRotCounter += Input.GetAxis("Mouse Y") * yMoveThreshold * Time.deltaTime;
    yRotCounter = Mathf.Clamp(yRotCounter, yMinLimit, yMaxLimit);
    transform.localEulerAngles = new Vector3(-yRotCounter, xRotCounter, 0);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity set particle properties through script 
Csharp :: DateTime2 error in EF Blazor Web Application 
Csharp :: get path revit link unloaded 
Csharp :: visual studio pre build event not working 
Csharp :: how to change the scale of a gameobject in unity 
Csharp :: 409 conflict 
Csharp :: c# one dimensional dictionary 
Csharp :: custom player spawner mirror 
Csharp :: c# azure get vm get cpu usage 
Csharp :: c sharp making our custom function 
Csharp :: AR light estimation Unity 
Csharp :: how to unfocus a richtextbox windows forms 
Csharp :: c# hardcode datetime quoting 
Csharp :: AutoMapper Add Assemblies 
Csharp :: Computing a Cartesian product or Combinations with LINQ 
Csharp :: c# return propertty from each object in object lpist 
Csharp :: vb.net convert int32 into boolean array stack overflow 
Csharp :: c# 2 timespan return yesterday 
Csharp :: www.elking.net 
Csharp :: add file to combobox c# 
Csharp :: c# picturebox zoom 
Csharp :: delete an object c# 
Csharp :: datagrid drop file wpf mvvm example 
Csharp :: get last id ef 
Csharp :: Maximum Points You Can Obtain from Cards 
Csharp :: c sharp tenery operator with callin gmethods 
Csharp :: how to reset checkbox visual studio c# 
Csharp :: replace update claims c# 
Csharp :: source a listbox by property of object c# 
Csharp :: eager loading singleton c# dependency injection 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =