HeadPositionCheck (HeadCollisionCheck.cs)

February 9, 2024 ยท View on GitHub

Namespace: Unity.TinyCharacterController.Check


Summary:

HeadCollisionCheck is a component that performs upward object detection. It conducts upward detection considering the height set in CharacterSettings. It also considers slightly ambiguous detection, not just complete contact with other objects, and calls UnityEvents upon collision.

Features and Operation:

  • Upward Detection: Detects objects above the character's head.
  • Contact and Distance Calculation: Calculates whether there is contact with objects and the distance, and sets properties based on these calculations.
  • Collision Event Invocation: Invokes Unity Events when the head makes contact with objects.

Properties

NameDescription
_headPositionOffsetOffset from the head position, used to determine contact with objects above.
MaxHeightThe maximum distance at which upward objects can be detected.
_onContactUnity Event called when the head makes contact during the frame.
_onChangeInRangeExecutes a Unity Event when the value of InRange changes.
IsHitCollisionInThis FrameIndicates if the head is in contact with other objects during the frame.
DistanceFromRootPositionThe distance from the ContactPoint to the root position.
IsHeadContactIndicates if the head is in contact with other objects.
IsObjectOverheadIndicates if there is a collider within range above the head.
ContactPointThe contact point if IsHeadContact is true, otherwise, the head position.
ContactedObjectThe collided GameObject, null if IsHeadContact is false.

Methods

  • There are no public methods.