SHARE
TWEET

Untitled

a guest Jul 21st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class PlayerMovement : MonoBehaviour
  7. {
  8.  
  9.     public float moveSpeed = 5.0f;
  10.     float x, z;
  11.  
  12.     public bool canMove = false;
  13.     public float jumpforce;
  14.     void FixedUpdate()
  15.     {
  16.         if (canMove==true)
  17.         {
  18.             x = 0;
  19.             z = 0;
  20.             // check to see if the W or S key are being pressed.  
  21.             z = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
  22.             // check to see if the A or D key are being pressed.  
  23.             x = Input.GetAxis("Horizontal") * Time.deltaTime * (moveSpeed / 2);
  24.             // Move the character
  25.             transform.Translate(x, 0, z);
  26.             if (Input.GetKeyDown("space"))
  27.             {
  28.                 transform.Translate(Vector3.up * jumpforce * Time.deltaTime, Space.World);
  29.             }
  30.         }
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top