PlayerController laufen funktioniert jetzt

This commit is contained in:
2026-06-19 12:34:03 +02:00
parent 65166c14a6
commit 22c4e0d7a9
+8 -4
View File
@@ -19,19 +19,23 @@ public class PlayerController : MonoBehaviour
position = Vector3.zero; position = Vector3.zero;
if (Input.GetKey(KeyCode.W)) if (Input.GetKey(KeyCode.W))
{ {
position += Vector3.forward; position += Vector3.forward * speed;
} }
if (Input.GetKey(KeyCode.A)) if (Input.GetKey(KeyCode.A))
{ {
position += Vector3.left; position += Vector3.left * speed;
} }
if (Input.GetKey(KeyCode.S)) if (Input.GetKey(KeyCode.S))
{ {
position += Vector3.back; position += Vector3.back * speed;
} }
if (Input.GetKey(KeyCode.D)) if (Input.GetKey(KeyCode.D))
{ {
position += Vector3.right; position += Vector3.right * speed;
} }
} }
private void FixedUpdate()
{
rb.linearVelocity = position.normalized * speed;
}
} }