Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class PlayerMovement : MonoBehaviour {
- public float moveSpeed = 10.0f;
- public float rotateSpeed = 5.0f;
- public float walkSpeed = 10.0f;
- public float runSpeed = 60.0f;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if(Input.GetKey ("w") ) {
- Transform.Translate((Vector3.forward)* moveSpeed * Time.deltaTime);
- Debug.Log("Pressing W key.")
- }
- if(Input.GetKey ("s") ) {
- Transform.Translate((Vector3.back)* moveSpeed * Time.deltaTime);
- Debug.Log("Pressing S key.")
- }
- if(Input.GetKey ("a") ) {
- transform.Rotate (Vector3.down * rotateSpeed);
- Debug.Log("Pressing A key.")
- }
- if(Input.GetKey ("d") ) {
- transform.Rotate (Vector3.up * rotateSpeed);
- Debug.Log("Pressing D key.")
- }
- if(Input.GetKey("left shift") ) {
- moveSpeed = runSpeed;
- Debug.Log("Pressing Left Shift key.");
- }
- else{
- moveSpeed = walkSpeed;
- }
- if(Input.GetKey("space") ) {
- Transform.Translate((Vector3.up)* moveSpeed * Time.deltaTime);
- Debug.Log("Pressing Space key.")
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement