Advertisement
Nicknick10000

Movement.cs (Original)

Dec 14th, 2018
25,968
0
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 Movement : MonoBehaviour {
  6.  
  7.     public float movementSpeed;
  8.  
  9.     // Use this for initialization
  10.     void Start () {
  11.  
  12.     }
  13.  
  14.     //Update is called once per frame
  15.     void FixedUpdate () {
  16.  
  17.         if (Input.GetKey (KeyCode.LeftShift) && Input.GetKey ("w")) {
  18.             transform.position += transform.TransformDirection (Vector3.forward) * Time.deltaTime * movementSpeed * 2.5f;
  19.         }   else if (Input.GetKey ("w") && !Input.GetKey (KeyCode.LeftShift)) {
  20.             transform.position += transform.TransformDirection (Vector3.forward) * Time.deltaTime * movementSpeed;
  21.         }   else if (Input.GetKey ("s")) {
  22.             transform.position -= transform.TransformDirection (Vector3.forward) * Time.deltaTime * movementSpeed;
  23.         }
  24.  
  25.         if (Input.GetKey ("a") && !Input.GetKey ("d")) {
  26.                 transform.position += transform.TransformDirection (Vector3.left) * Time.deltaTime * movementSpeed;
  27.             } else if (Input.GetKey ("d") && !Input.GetKey ("a")) {
  28.                 transform.position -= transform.TransformDirection (Vector3.left) * Time.deltaTime * movementSpeed;
  29.             }
  30.         }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement