So, I decided to create a ground-check with a boxcast or the overlapbox. I tried both, turned out that both are framerate-dependent, meaning if I set the Application.targetFramerate to like 15, the player would clip through the floor, which is 1 unit tall (And this may sound weird but I don’t use the character controller, nor the rigidbody in this particular case)
I tried:
- Changing FixedUpdate() to LateUpdate(), Update()
- Lowering the TimeStep, probably not the best idea
Code (OverlapBox):
private void FixedUpdate()
{
Collider[ ] GroundOverlaps = Physics.OverlapBox(GroundCheck.position, new Vector3(0.5f, 0.5f, 0.5f), Quaternion.identity, GroundLayers);
if(GroundOverlaps.Length > 0)
{
Grounded = true;
}
else if(GroundOverlaps.Length == 0 && Grounded)
{
Grounded = false;
}
}
Code (BoxCast):
private void FixedUpdate()
{
if(Physics.BoxCast(GroundCheck.position, new Vector3(0.5f, 0.5f, 0.5f), Vector3.down, Quaternion.identity, 1, GroundLayers))
{
Grounded = true;
}
else
{
Grounded = false;
}
}
Is there any way to make those framerate independent? Please help, I would really appreciate it