#Unity 6 Rigidbody ground check
1 messages · Page 1 of 1 (latest)
getting 9.46 ms return from that. wanting something abit faster. my current call is 5.629ms
Well, more specifically as the page details you should use GetContacts
Fair. i like that option i will see if anyone else has options
Also there's specific methods like this:
https://docs.unity3d.com/ScriptReference/Collider.OnCollisionStay.html
private bool IsGrounded()
{
Ray ray = new(this.transform.position + Vector3.up * 0.25f, Vector3.down);
Debug.DrawRay(this.transform.position + Vector3.up * 0.25f, Vector3.down, Color.red);
if (Physics.SphereCast(ray, 0.3f)) // THIS ISNT WORKING BUT IT WONT IN CURRENT FORMAT JUST COPIED FROM CURRENT UNFISHED SCRIPT
return true;
else return false;
}
decided to just go
{
float sphereCastRadius = capsuleCollider.radius * _groundCheckRadiusMultiplier;
Physics.SphereCast(rb.position, sphereCastRadius, Vector3.down, out _groundCheckHit);
playerCenterToGroundDisatnce = _groundCheckHit.distance + sphereCastRadius;
return ((playerCenterToGroundDisatnce >= capsuleCollider.bounds.extents.y - _groundCheckDistanceTolerance) &&
(playerCenterToGroundDisatnce <= capsuleCollider.bounds.extents.y + _groundCheckDistanceTolerance));
}