Guest User

Untitled

a guest
Jul 25th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 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.     void Update ()
  10.     {
  11.  
  12.         //Movement ();     
  13.     }
  14.  
  15.     void Movement ()
  16.     {
  17.         if (Input.GetKey (KeyCode.UpArrow)) {
  18.             Debug.Log ("Key UpArrow Pressed.");
  19.        
  20.             this.transform.Translate (new Vector3 (0, 0, moveSpeed * Time.deltaTime));
  21.         } else if (Input.GetKey (KeyCode.DownArrow)) {
  22.             Debug.Log ("Key DownArrow Pressed.");
  23.        
  24.             this.transform.Translate (new Vector3 (0, 0, -moveSpeed * Time.deltaTime));
  25.         }
  26.  
  27.  
  28.         if (Input.GetKey (KeyCode.LeftArrow)) {
  29.             if (canMoveSideways) {
  30.                 Debug.Log ("Key LeftArrow Pressed.");
  31.        
  32.                 this.transform.Translate (new Vector3 (moveSpeed * Time.deltaTime, 0, 0));
  33.             } else {
  34.                 Debug.Log ("Key LeftArrow Pressed: Rotate");
  35.                
  36.                 this.transform.Rotate (new Vector3 (0, -rotateSpeed * Time.deltaTime, 0));
  37.             }
  38.        
  39.         } else if (Input.GetKey (KeyCode.RightArrow)) {
  40.             if (canMoveSideways)
  41.  
  42.                 Debug.Log ("Key RightArrow Pressed.");
  43.        
  44.             this.transform.Translate (new Vector3 (-moveSpeed * Time.deltaTime, 0, 0));
  45.        
  46.        
  47.     }
  48.         else
  49.         {
  50.             Debug.Log ("Key RightArrow Pressed: Rotate");
  51.  
  52.             this.transform.Rotate (new Vector3 (0, rotateSpeed * Time.deltaTime, 0));
  53.         }
  54.     }
  55. }
  56. if ( Input.GetKey ( KeyCode.W ) )
  57. }
  58.     {
  59.         Debug.Log ( "Key W Pressed." );
  60.        
  61.         this.transform.Translate ( new Vector3 ( 0, moveSpeed * Time.deltaTime, 0 ) );
  62.     }
  63.     else if (Input.GetKey ( KeyCode.S ))
  64.     {
  65.         Debug.Log ( "Key S Pressed." );
  66.        
  67.         this.transform.Translate ( new Vector3 ( 0, -moveSpeed * Time.deltaTime,0 ) );
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment