GroundCheck

February 9, 2024 ยท View on GitHub

Namespace: Unity.TinyCharacterController.Check


Summary:

GroundCheck is a component that performs collision detection with the ground. It determines whether the ground is present, the orientation of the contact surface, information about the contact object, and notifies any changes in the ground object. The calculations for this component are executed at the timing of OnUpdate.

Features and Operation:

  • Ground Detection: Detects collision with the ground and determines whether it is in contact.
  • Ground Contact Information Retrieval: Provides information about the presence of the ground, the orientation of the contact surface, and the contact object.
  • Ground Object Change Notification: Issues a Unity Event when there is a change in the ground object.

Properties

NameDescription
_ambiguousDistanceThe maximum distance at which the character can be recognized as being on the ground, used for ambiguous ground detection.
_preciseDistanceThe distance at which the character is recognized as being on the ground, used for strict ground detection.
_maxSlopeThe maximum slope at which the ground is recognized as "ground."
_onChangeGroundObjectUnity Event invoked when the ground collider changes.
IsOnGroundIndicates if the character is in contact with the ground.
IsFirmlyOnGroundIndicates if the character is firmly in contact with the ground.
MaxGroundCheckDistanceThe maximum distance for ground check.
GroundColliderThe current ground collider.
GroundSurfaceNormalThe orientation of the ground surface.
GroundContactPointThe contact point with the ground.
DistanceFromGroundThe distance from the ground.
GroundObjectThe ground object.
IsChangeGroundObjectIndicates if the ground object has changed in the current frame.

Methods

NameFunction
public bool Raycast( Vector3 position, float distance, out RaycastHit hit )Performs a Raycast that ignores the Collider attached to the character.