Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerMovement : MonoBehaviour
- {
- public Rigidbody rb;
- public float forwardForce = 2500f;
- public float sidewaysForce = 100f;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void FixedUpdate()
- {
- rb.AddForce(0, 0, this.forwardForce * Time.deltaTime);
- if(Input.GetKey("d"))
- {
- rb.AddForce(this.sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
- }
- else if(Input.GetKey("a"))
- {
- rb.AddForce(-this.sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
- }
- }
- }
Add Comment
Please, Sign In to add comment