Advertisement
Guest User

Untitled

a guest
Feb 10th, 2018
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2.  
  3. public class PlayerMovement : MonoBehaviour {
  4.  
  5.  
  6. public Rigidbody rb;
  7. public PlayerMovement movement;
  8. public PlayerMovement rotation;
  9.  
  10. public float forwardForce = 2000f;
  11. public float sidewaysForce = 50f;
  12. public float gravity;
  13. //bool PlayerMovement.freezeRotation = true;
  14.  
  15. // Use this for initialization
  16. void Start ()
  17. {
  18. rb.useGravity = true;
  19.  
  20. }
  21.  
  22. void FixedUpdate ()
  23. {
  24.  
  25. rb.AddForce(Vector3.down * gravity * rb.mass);
  26.  
  27.  
  28. rb.AddForce(0, 0, forwardForce * Time.deltaTime);
  29.  
  30. if ( Input.GetKey("d") )
  31. {
  32. rb.AddForce(sidewaysForce, 0, 0, ForceMode.VelocityChange);
  33. }
  34. if (Input.GetKey("a"))
  35. {
  36. rb.AddForce(-sidewaysForce, 0, 0, ForceMode.VelocityChange);
  37. }
  38.  
  39. if (rb.position.y < 0.9f)
  40. {
  41. FindObjectOfType<GameManager>().GameOver();
  42. }
  43. }
  44. }
Advertisement
RAW Paste Data Copied
Advertisement