So at first i thought something was wrong with my build but it seems like when i used another laptop to test my game The character would jump randomy High and it happend more often on different computers so i go on my main one where i build the game an after a couple jumps i realize my play can randomy jump high for no reason and i dont understand why.
This is my code for jumping
public float playerspd = 300f;
public Rigidbody rb;
public float jumpForce = 1f;
public bool isGrounded = false;
void Start()
{
//_Controller = GetComponent<CharacterController>();
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
PlayerMovement();
if (isGrounded == true && Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
//rb.velocity = new Vector3(rb.velocity.x, jumpForce, rb.velocity.z);
}
}
And this is the Collision detection
private GameMaster _gamMaster;
private PlayerMover _player;
void Start()
{
_player = GetComponent<PlayerMover>();
_gamMaster = GameObject.Find("GameMaster").GetComponent<GameMaster>();
}
void OnCollisionEnter(Collision other)
{
switch (other.gameObject.tag)
{
case "jumpAble":
_player.isGrounded = true;
break;
}
}
void OnCollisionExit(Collision other)
{
switch (other.gameObject.tag)
{
case "jumpAble":
_player.isGrounded = false;
break;
}
}
This is the game where he constantly jumps excessively high
Edit: so i fixed the jumping code by learning a little bit about fixed update and i put my input in update and the addforce in the fixedupdate and it seems like that fixed the random jumping problem but my charactes movement is still choppy. ill add a question somewhere else since i found out about the jump