From ec658080c66c93e8ff1e29d66d93d8995a9d2b2a Mon Sep 17 00:00:00 2001 From: logzinga <65839350+logzinga@users.noreply.github.com> Date: Fri, 10 Feb 2023 10:54:54 +1100 Subject: [PATCH] movement with the W key --- Assets/Scripts/PlayerMovement.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index e110952..bb9f2a4 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -4,6 +4,11 @@ using UnityEngine; public class PlayerMovement : MonoBehaviour { + + public Rigidbody rb; + + public float forwardForce = 1000f; + // Start is called before the first frame update void Start() { @@ -11,8 +16,10 @@ public class PlayerMovement : MonoBehaviour } // Update is called once per frame - void Update() + void FixedUpdate() { - + if (Input.GetKey("W")) { + rb.AddForce(forwardForce * Time.deltaTime, 0, 0); + } } }