Interface IKinematicCharacterProcessor<C>
Interface implemented by structs meant to be passed as parameter to KinematicCharacterAspect in order to customize internal character update logic.
Namespace: Unity.CharacterController
Syntax
public interface IKinematicCharacterProcessor<C>
where C : struct
Type Parameters
Name | Description |
---|---|
C | The type of the character "context" struct created by the user |
Methods
CanCollideWithHit(ref C, ref KinematicCharacterUpdateContext, in BasicHit)
Determines if a hit can be collided with or not.
Declaration
bool CanCollideWithHit(ref C context, ref KinematicCharacterUpdateContext baseContext, in BasicHit hit)
Parameters
Type | Name | Description |
---|---|---|
C | context | The user context struct holding global data meant to be accessed during the character update |
KinematicCharacterUpdateContext | baseContext | The built-in context struct holding global data meant to be accessed during the character update |
BasicHit | hit | The evaluated hit |
Returns
Type | Description |
---|---|
Boolean | Return true if the hit can be collided with, return false if not. |
IsGroundedOnHit(ref C, ref KinematicCharacterUpdateContext, in BasicHit, Int32)
Determines if the character can be grounded the hit or not.
Declaration
bool IsGroundedOnHit(ref C context, ref KinematicCharacterUpdateContext baseContext, in BasicHit hit, int groundingEvaluationType)
Parameters
Type | Name | Description |
---|---|---|
C | context | The user context struct holding global data meant to be accessed during the character update |
KinematicCharacterUpdateContext | baseContext | The built-in context struct holding global data meant to be accessed during the character update |
BasicHit | hit | The evaluated hit |
Int32 | groundingEvaluationType | An identifier meant to indicate what type of grounding evaluation is being done at the moment of calling this. |
Returns
Type | Description |
---|---|
Boolean |
OnMovementHit(ref C, ref KinematicCharacterUpdateContext, ref KinematicCharacterHit, ref float3, ref Single, float3, Single)
Determines what happens when the character detects a hit during its movement phase.
Declaration
void OnMovementHit(ref C context, ref KinematicCharacterUpdateContext baseContext, ref KinematicCharacterHit hit, ref float3 remainingMovementDirection, ref float remainingMovementLength, float3 originalVelocityDirection, float hitDistance)
Parameters
Type | Name | Description |
---|---|---|
C | context | The user context struct holding global data meant to be accessed during the character update |
KinematicCharacterUpdateContext | baseContext | The built-in context struct holding global data meant to be accessed during the character update |
KinematicCharacterHit | hit | The evaluated hit |
float3 | remainingMovementDirection | The direction of the movement vector that remains to be processed |
Single | remainingMovementLength | The magnitude of the movement vector that remains to be processed |
float3 | originalVelocityDirection | The original direction of the movement vector before any movement projection happened |
Single | hitDistance | The distance of the detected hit |
OverrideDynamicHitMasses(ref C, ref KinematicCharacterUpdateContext, ref PhysicsMass, ref PhysicsMass, BasicHit)
Provides an opportunity to modify the physics masses used to solve impulses between characters and detected hit bodies.
Declaration
void OverrideDynamicHitMasses(ref C context, ref KinematicCharacterUpdateContext baseContext, ref PhysicsMass characterMass, ref PhysicsMass otherMass, BasicHit hit)
Parameters
Type | Name | Description |
---|---|---|
C | context | The user context struct holding global data meant to be accessed during the character update |
KinematicCharacterUpdateContext | baseContext | The built-in context struct holding global data meant to be accessed during the character update |
PhysicsMass | characterMass | The mass of the character |
PhysicsMass | otherMass | The mass of the other body that we've detected a hit with |
BasicHit | hit | The evaluated hit with the dynamic body |
ProjectVelocityOnHits(ref C, ref KinematicCharacterUpdateContext, ref float3, ref Boolean, ref BasicHit, in DynamicBuffer<KinematicVelocityProjectionHit>, float3)
Requests that the character velocity be projected on the hits detected so far in the character update.
Declaration
void ProjectVelocityOnHits(ref C context, ref KinematicCharacterUpdateContext baseContext, ref float3 velocity, ref bool characterIsGrounded, ref BasicHit characterGroundHit, in DynamicBuffer<KinematicVelocityProjectionHit> velocityProjectionHits, float3 originalVelocityDirection)
Parameters
Type | Name | Description |
---|---|---|
C | context | The user context struct holding global data meant to be accessed during the character update |
KinematicCharacterUpdateContext | baseContext | The built-in context struct holding global data meant to be accessed during the character update |
float3 | velocity | The character velocity that needs to be projected |
Boolean | characterIsGrounded | Whether the character is grounded or not |
BasicHit | characterGroundHit | The current effective ground hit of the character |
DynamicBuffer<KinematicVelocityProjectionHit> | velocityProjectionHits | |
float3 | originalVelocityDirection | The original velocity direction of the character at the beginning of the character update, before any projection has happened |
UpdateGroundingUp(ref C, ref KinematicCharacterUpdateContext)
Requests that the grounding up direction should be updated.
Declaration
void UpdateGroundingUp(ref C context, ref KinematicCharacterUpdateContext baseContext)
Parameters
Type | Name | Description |
---|---|---|
C | context | The user context struct holding global data meant to be accessed during the character update |
KinematicCharacterUpdateContext | baseContext | The built-in context struct holding global data meant to be accessed during the character update |