Advertisement
Guest User

Movement script

a guest
Oct 31st, 2017
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MovementScript : MonoBehaviour
  6. {
  7.     public float FwdSpeed = 1f;
  8.  
  9.     void Start()
  10.     {
  11.         Cursor.visible = false;
  12.     }
  13.  
  14.     void Update()
  15.     {
  16.         if (Input.GetKeyDown("escape"))
  17.             Cursor.visible = true;
  18.  
  19.         if (Input.GetKey (KeyCode.W))
  20.         {
  21.             transform.Translate (Vector3.forward * Time.deltaTime * FwdSpeed);
  22.         }
  23.  
  24.         else if (Input.GetKey (KeyCode.S))
  25.         {
  26.             transform.Translate (Vector3.back * Time.deltaTime * FwdSpeed);
  27.         }
  28.     }
  29. }
Advertisement
RAW Paste Data Copied
Advertisement