-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMouseCharacterControl.cs
More file actions
39 lines (30 loc) · 1 KB
/
MouseCharacterControl.cs
File metadata and controls
39 lines (30 loc) · 1 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
/*======================================================================
* MouseCharacterControl
*
* Programmer: David Torrente
*
* Description: This class rotates the player to reposition the forward
* movement. It does not rotate the head up and down nor does it
* actually change the position coordinates. This code goes on the
* actual player object.
* ====================================================================*/
using UnityEngine;
using System.Collections;
public class MouseCharacterControl : MonoBehaviour {
public int playerNum;
private float rotationX;
private float sensitivityX;
private Vector3 moveDirection;
void Start ()
{
sensitivityX = 15F;
moveDirection = Vector3.zero;
rotationX = 0F;
}// END START
void Update ()
{
rotationX += Input.GetAxis("MouseX"+playerNum) * sensitivityX;
moveDirection = new Vector3(0,rotationX,0);
transform.localEulerAngles = moveDirection;
}//END UPDATE
}//END MOUSECHARACTERCONTROL