Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class PlayerController : MonoBehaviour
- {
- [SerializeField] float horsePower = 0f;
- private float turnSpeed = 35.0f;
- private float horizontalInput;
- private float forwardInput;
- private Rigidbody playerRb;
- private void Start()
- {
- playerRb = GetComponent<Rigidbody>();
- }
- void FixedUpdate()
- {
- //Move the vehicle forward
- playerRb.AddRelativeForce(Vector3.forward * forwardInput * horsePower);
- //have vehicle rotate as it turns
- transform.Rotate(Vector3.up * Time.deltaTime * turnSpeed * horizontalInput);
- }
- }
Advertisement
Comments
-
- An annoying way to move the vehicle forward as I have to mess with the centre of mass position and horse power
Add Comment
Please, Sign In to add comment
Advertisement