forked from orenjp/Mage-It
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerController.cs
28 lines (24 loc) · 920 Bytes
/
PlayerController.cs
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
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float rotationSpeed;
public float forwardSpeed;
private CharacterController playerController;
// Use this for initialization
void Start () {
playerController = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update () {
if (Input.GetKeyUp("space") && playerController.isGrounded)
{
playerController.Move(Vector3.up);
}
transform.Rotate(0, Input.GetAxis("Horizontal") * rotationSpeed, 0);
//transform.Rotate(0, 1 * rotationSpeed / 10, 0);
Vector3 forward = transform.TransformDirection(Vector3.forward);
float speed = forwardSpeed * Input.GetAxis("Vertical");
playerController.SimpleMove(forward * speed);
//playerController.SimpleMove(forward*forwardSpeed);
}
}