isKinematic im Script geändert um das springen zu verbessern. Weiß aber noch nicht ob das die beste Lösung ist

This commit is contained in:
Jan Breitkreuz 2024-06-19 12:55:59 +02:00
parent aedc9d659e
commit d91ab65c06

View File

@ -39,10 +39,10 @@ public class PlayerMoveScript : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
jump();
move(); move();
look(); look();
lockCursor(); lockCursor();
jump();
} }
@ -65,11 +65,12 @@ public class PlayerMoveScript : MonoBehaviour
public void jump() public void jump()
{ {
if(Input.GetKeyDown(KeyCode.Space)) if(Input.GetKey(KeyCode.Space))
{ {
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.down), checkForJump)) if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.down), checkForJump))
{ {
rb.velocity = new Vector3(rb.velocity.x, 0, rb.velocity.z); rb.isKinematic = true;
rb.isKinematic = false;
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse); rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
} }
} }