Advertisement
Guest User

Untitled

a guest
Jul 20th, 2015
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PlayerMovement : MonoBehaviour
  5. {
  6.     public float moveSpeed = 5.0f;
  7.     public float rotateSpeed = 60.0f;
  8.     public bool canMoveSideways = false;
  9.        
  10.     void Update ()
  11.     {
  12.         //Movement ();
  13.     }
  14.     void Movement ()
  15.     {
  16.         if (Input.GetKey (KeyCode.UpArrow))
  17.         {
  18.             Debug.Log ("Key UpArrow Pressed.");
  19.             this.transform.Translate (new Vector3 (0, 0, moveSpeed * Time.deltaTime));
  20.         }
  21.         else if (Input.GetKey (KeyCode.DownArrow))
  22.         {
  23.             Debug.Log ("Key DownArrow Pressed.");
  24.             this.transform.Translate (new Vector3 (0, 0, -moveSpeed * Time.deltaTime));
  25.         }
  26.         if (Input.GetKey (KeyCode.LeftArrow))
  27.         {
  28.             if (canMoveSideways)
  29.             {
  30.                 Debug.Log ("Key LeftArrow Pressed.");
  31.                 this.transform.Translate (new Vector3 (moveSpeed * Time.deltaTime, 0, 0));
  32.             }
  33.             else
  34.             {
  35.                 Debug.Log ("Key LeftArrow Pressed: Rotate");
  36.                 this.transform.Rotate (new Vector3 (0, -rotateSpeed * Time.deltaTime, 0));
  37.             }
  38.         }
  39.         else if (Input.GetKey (KeyCode.RightArrow))
  40.         {
  41.             if (canMoveSideways)
  42.                 Debug.Log ("Key RightArrow Pressed.");
  43.             this.transform.Translate (new Vector3 (-moveSpeed * Time.deltaTime, 0, 0));
  44.         }
  45.         else
  46.         {
  47.             Debug.Log ("Key RightArrow Pressed: Rotate");
  48.             this.transform.Rotate (new Vector3 (0, rotateSpeed * Time.deltaTime, 0));
  49.         }
  50.     }
  51. }
  52. if ( Input.GetKey ( KeyCode.W ) ) // THIS IS THE ONE I NEED HELP ON!!!
  53. }
  54. {
  55.     Debug.Log ( "Key W Pressed." );
  56.     Update 6: this.transform.Translate ( new Vector3 ( 0, moveSpeed * Time.deltaTime, 0 ) );
  57. }
  58. else if (Input.GetKey ( KeyCode.S ))
  59. {
  60.     Debug.Log ( "Key S Pressed." );
  61.     this.transform.Translate ( new Vector3 ( 0, -moveSpeed * Time.deltaTime,0 ) );
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement