Advertisement
sovietcat

RollingBall

Jul 22nd, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class PlayerMovement : MonoBehaviour {
  4.  
  5.     public Rigidbody rb;
  6.     public float pushSpeed = 2000f;
  7.     public float moveSpeed = 100f;
  8.  
  9.     // Runs once when starting game
  10.     void Start () {
  11.  
  12.     }
  13.    
  14.     // Update is called once per frame
  15.     void FixedUpdate () {
  16.  
  17.         if (Input.GetKey("d"))
  18.         {
  19.             rb.AddForce(moveSpeed * Time.fixedDeltaTime, 0, 0);
  20.         }
  21.  
  22.         if (Input.GetKey("s"))
  23.         {
  24.             rb.AddForce(0, 0, -moveSpeed * Time.fixedDeltaTime);
  25.         }
  26.  
  27.         if (Input.GetKey("a"))
  28.         {
  29.             rb.AddForce(-moveSpeed * Time.fixedDeltaTime, 0, 0);
  30.         }
  31.  
  32.         if (Input.GetKey("w"))
  33.         {
  34.             rb.AddForce(0, 0, moveSpeed * Time.fixedDeltaTime);
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement