Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PlayerMovement : MonoBehaviour {
  5.  
  6. public float moveSpeed = 10.0f;
  7. public float rotateSpeed = 5.0f;
  8. public float walkSpeed = 10.0f;
  9. public float runSpeed = 60.0f;
  10.  
  11. // Use this for initialization
  12. void Start () {
  13.  
  14. }
  15.  
  16. // Update is called once per frame
  17. void Update () {
  18. if(Input.GetKey ("w") ) {
  19. Transform.Translate((Vector3.forward)* moveSpeed * Time.deltaTime);
  20. Debug.Log("Pressing W key.")
  21. }
  22.  
  23. if(Input.GetKey ("s") ) {
  24. Transform.Translate((Vector3.back)* moveSpeed * Time.deltaTime);
  25. Debug.Log("Pressing S key.")
  26. }
  27.  
  28. if(Input.GetKey ("a") ) {
  29. transform.Rotate (Vector3.down * rotateSpeed);
  30. Debug.Log("Pressing A key.")
  31. }
  32.  
  33. if(Input.GetKey ("d") ) {
  34. transform.Rotate (Vector3.up * rotateSpeed);
  35. Debug.Log("Pressing D key.")
  36. }
  37.  
  38. if(Input.GetKey("left shift") ) {
  39. moveSpeed = runSpeed;
  40. Debug.Log("Pressing Left Shift key.");
  41. }
  42.  
  43. else{
  44. moveSpeed = walkSpeed;
  45. }
  46.  
  47. if(Input.GetKey("space") ) {
  48. Transform.Translate((Vector3.up)* moveSpeed * Time.deltaTime);
  49. Debug.Log("Pressing Space key.")
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement