Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerMovement : MonoBehaviour
- {
- public float speed = 5.0f;
- public float rotateSpeed = 20.0f;
- void Update ()
- {
- Movement ();
- }
- void Movement ()
- {
- //Movement
- if ( Input.GetKey (KeyCode.W) )
- {
- Debug.Log ( "Key W Pressed" );
- this.transform.Translate ( new Vector3 ( 0,0,speed * Time.deltaTime ) );
- }
- if ( Input.GetKey (KeyCode.A) )
- {
- Debug.Log ( "Key A Pressed" );
- this.transform.Translate ( new Vector3 ( -speed * Time.deltaTime,0,0) );
- }
- if ( Input.GetKey (KeyCode.S) )
- {
- Debug.Log ( "Key S Pressed" );
- this.transform.Translate ( new Vector3 ( 0,0, -speed * Time.deltaTime ) );
- }
- if ( Input.GetKey (KeyCode.D) )
- {
- Debug.Log ( "Key D Pressed" );
- this.transform.Translate ( new Vector3 ( speed * Time.deltaTime,0,0 ) );
- }
- if ( Input.GetKey (KeyCode.Space) )
- {
- Debug.Log ( "Key Space Pressed" );
- this.transform.Translate ( new Vector3 ( 0,speed * Time.deltaTime,0 ) );
- }
- if ( Input.GetKey (KeyCode.LeftControl) )
- {
- Debug.Log ( "Key Alt Pressed" );
- this.transform.Translate ( new Vector3 ( 0,-speed * Time.deltaTime,0 ) );
- }
- //Rotation
- if ( Input.GetKey (KeyCode.LeftArrow) )
- {
- Debug.Log ( "Key LeftArrow Pressed: Rotate" );
- this.transform.Rotate ( new Vector3 ( 0, -rotateSpeed * Time.deltaTime, 0 ) );
- }
- if ( Input.GetKey (KeyCode.RightArrow) )
- {
- Debug.Log ( "Key RightArrow Pressed: Rotate" );
- this.transform.Rotate ( new Vector3 ( 0, rotateSpeed * Time.deltaTime, 0 ) );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement