
It looks like you're new here. If you want to get involved, click one of these buttons!
I'm making my version of cubethon by adding new mechanics to it as a jump and a crouch mechanic and i'm stuck in a weird jump bug that i saw lately its that the jumps are not equal
im adding a force in the y axis while jumping but idk why i see a diffrence between the jumps i tried changing addForce to rb.velocity but i got the same issue
here is some Details :
private float jumpForce = 10f;
private Vector3 movedir;
public Rigidbody rb;
public float sideWaySpeed = 100f;
private float hori;
private bool jumpInput = false;
public LayerMask Ground;
private bool CrouchCheck;
public float forceSpeed = 75f
public float minSpeedForce = 55f
public float maxSpeedForce = 75f;
private void Update()
{
hori = Input.GetAxisRaw("Horizontal");
jumpInput = Input.GetButtonDown("Jump");
CrouchCheck = Input.GetKey(KeyCode.C);
}
private void Jump()
{
if (!CrouchCheck&&jumpInput && Grounded())
{
rb.AddForce(Vector3.up * jumpForce * Time.fixedDeltaTime, ForceMode.Impulse);
}
}
private bool Grounded()
{
return Physics.Raycast(transform.position, Vector3.down,1f, Ground);
}
Try asking on the brackeys discord server since this it will take longer to get answers on this site : )
Good Luck
Answers
you are multiplying by Time.fixedDeltaTime which is used for fixed update, however jump is being called from update so you need to multiply by Time.DeltaTime which is used for Update.
so i just need to change Time.fixedDeltaTime to DeltaTime ?
yes
well nothing has changed :(