Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class PlayerMovement : MonoBehaviour {
- public Rigidbody rb;
- public PlayerMovement movement;
- public PlayerMovement rotation;
- public float forwardForce = 2000f;
- public float sidewaysForce = 50f;
- public float gravity;
- //bool PlayerMovement.freezeRotation = true;
- // Use this for initialization
- void Start ()
- {
- rb.useGravity = true;
- }
- void FixedUpdate ()
- {
- rb.AddForce(Vector3.down * gravity * rb.mass);
- rb.AddForce(0, 0, forwardForce * Time.deltaTime);
- if ( Input.GetKey("d") )
- {
- rb.AddForce(sidewaysForce, 0, 0, ForceMode.VelocityChange);
- }
- if (Input.GetKey("a"))
- {
- rb.AddForce(-sidewaysForce, 0, 0, ForceMode.VelocityChange);
- }
- if (rb.position.y < 0.9f)
- {
- FindObjectOfType<GameManager>().GameOver();
- }
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement