@ninjaconsultant I see, thanks for the details. It seems you're bit further in understanding this part of VRTK. I think you're approach to use Grounded/Airborne is sound - and in my head it shouldn't continuously fire - seems like a bug.
It seems to be located in here VRTK.Prefabs.Locomotion.BodyRepresentation.BodyRepresentationProcessor.CheckIfCharacterControllerIsGrounded
protected virtual bool CheckIfCharacterControllerIsGrounded()
{
if (Character.isGrounded)
{
return true;
}
HeapAllocationFreeReadOnlyList<Collider> hitColliders = PhysicsCast.OverlapSphereAll(
null,
Character.transform.position + (Vector3.up * (Character.radius - Character.skinWidth - 0.001f)),
Character.radius,
1 << Character.gameObject.layer);
foreach (Collider hitCollider in hitColliders)
{
if (hitCollider != Character
&& hitCollider != RigidbodyCollider
&& !ignoredColliders.Contains(hitCollider)
&& !Physics.GetIgnoreLayerCollision(
hitCollider.gameObject.layer,
Character.gameObject.layer)
&& !Physics.GetIgnoreLayerCollision(hitCollider.gameObject.layer, PhysicsBody.gameObject.layer))
{
return true;
}
}
return false;
}
That Character.isGrounded returns false (even when on the ground while you move - maybe an issue with how that function works or maybe something is moving that controller a tiny bit along y axis making it ungrounded.
It seems that guys have seen that and put some workaround in place by using PhysicsCast.OverlapSphereAll
the only problem is as you can see it'll ignore layer that CharacterController
is on in this case Default
, the floor on farm demo is also on that layer, if you change it to something else it'll be captured in that call and function will return true
.
This makes it better as grounded/airborne will no longer continuously trigger, when you climb though - this Character.isGrounded
returns true sometimes and toggles events.
Perhaps you can look into exact reason why this happens and getting that fixed, maybe as a workaround you can combine that with check for Climbinbing
state to filter out those Grounded/Airborne false-positives.