-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraLook.cs
More file actions
50 lines (34 loc) · 1.07 KB
/
CameraLook.cs
File metadata and controls
50 lines (34 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*======================================================================
* CameraLook
*
* Programmer: David Torrente
*
* Description: This class rotates the camera in order to allow the
* player to look up and down. To use it properly, place this code on
* a camera which is the child of the player.
* ====================================================================*/
using UnityEngine;
using System.Collections;
public class CameraLook : MonoBehaviour {
public int playerNum;
private float minimumY;
private float maximumY;
private float rotationY;
private float sensitivityY;
private Vector3 moveDirection;
void Start ()
{
Cursor.visible = false;
minimumY = -60F;
maximumY = 60F;
rotationY = 0F;
sensitivityY = 15F;
}
void Update ()
{
rotationY += Input.GetAxis("MouseY"+playerNum) * sensitivityY;
rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
moveDirection = new Vector3(-rotationY,0,0);
transform.localEulerAngles = moveDirection;
}
}//END MouseLook