Character Controller Pro 1.4.11
A 2D/3D character controller asset for Unity.
Lightbug.CharacterControllerPro.Core.CharacterActor Class Reference

This class represents a character actor. It contains all the character information, collision flags, collision events, and so on. It also responsible for the execution order of everything related to the character, such as movement, rotation, teleportation, rigidbodies interactions, body size, etc. Since the character can be 2D or 3D, this abstract class must be implemented in the two formats, one for 2D and one for 3D. More...

Inheritance diagram for Lightbug.CharacterControllerPro.Core.CharacterActor:
Lightbug.CharacterControllerPro.Core.PhysicsActor

Public Types

enum  SizeReferenceType { Top , Center , Bottom }
 
enum  CharacterVelocityMode { UseInputVelocity , UsePreSimulationVelocity , UsePostSimulationVelocity }
 
- Public Types inherited from Lightbug.CharacterControllerPro.Core.PhysicsActor
enum  RootMotionVelocityType { SetVelocity , SetPlanarVelocity , SetVerticalVelocity }
 Defines how the root velocity data is going to be applied to the actor. More...
 
enum  RootMotionRotationType { SetRotation , AddRotation }
 Defines how the root rotation data is going to be applied to the actor. More...
 

Public Member Functions

override void OnValidate ()
 
void SetUpRootMotion (bool updateRootPosition=true, bool updateRootRotation=true)
 Sets up root motion for this actor.
 
void SetUpRootMotion (bool updateRootPosition=true, RootMotionVelocityType rootMotionVelocityType=RootMotionVelocityType.SetVelocity, bool updateRootRotation=true, RootMotionRotationType rootMotionRotationType=RootMotionRotationType.AddRotation)
 Sets up root motion for this actor.
 
Vector3 GetGroundPointVelocity (Vector3 point)
 Returns the point velocity (Rigidbody API) of the ground at a given position.
 
string GetCharacterInfo ()
 Returns a concatenated string containing all the current collision information.
 
Vector3 GetCenter (Vector3 position)
 Gets the center of the collision shape.
 
Vector3 GetTop (Vector3 position)
 Gets the top most point of the collision shape.
 
Vector3 GetBottom (Vector3 position)
 Gets the bottom most point of the collision shape.
 
Vector3 GetTopCenter (Vector3 position)
 Gets the center of the top sphere of the collision shape.
 
Vector3 GetTopCenter (Vector3 position, Vector2 bodySize)
 Gets the center of the top sphere of the collision shape (considering an arbitrary body size).
 
Vector3 GetBottomCenter (Vector3 position, float bottomOffset=0f)
 Gets the center of the bottom sphere of the collision shape.
 
Vector3 GetBottomCenter (Vector3 position, Vector2 bodySize)
 Gets the center of the bottom sphere of the collision shape (considering an arbitrary body size).
 
Vector3 GetBottomCenterToTopCenter ()
 Gets the a vector that goes from the bottom center to the top center (topCenter - bottomCenter).
 
Vector3 GetBottomCenterToTopCenter (Vector2 bodySize)
 Gets the a vector that goes from the bottom center to the top center (topCenter - bottomCenter).
 
bool SetBodySize (Vector2 size)
 Checks if the new character size fits in place. If this check is valid then the real size of the character is changed.
 
void SetSize (Vector2 size, SizeReferenceType sizeReferenceType)
 Changes the body size of the actor. Additionaly, an overlap test can be performed beforehand in order to check if the character will fit or not. If the test failed (overlap detected), changes won't be applied. More...
 
bool CheckSize (Vector3 position, Vector2 size, in HitInfoFilter filter)
 Checks if the body fits in place by performing an overlap. More...
 
bool CheckSize (Vector3 position, Vector2 size)
 Checks if the body fits in place by performing an overlap. More...
 
bool CheckSize (Vector2 size, in HitInfoFilter filter)
 Checks if the body fits in place by performing an overlap. More...
 
bool CheckSize (Vector2 size)
 Checks if the body fits in place by performing an overlap. More...
 
bool CheckAndSetSize (Vector3 position, Vector2 size, in HitInfoFilter filter, SizeReferenceType sizeReferenceType=SizeReferenceType.Bottom)
 Checks if the body fits in place. If so, it automatically changes the size of the body. More...
 
bool CheckAndSetSize (Vector3 position, Vector2 size, SizeReferenceType sizeReferenceType=SizeReferenceType.Bottom)
 Checks if the body fits in place. If so, it automatically changes the size of the body. More...
 
bool CheckAndSetSize (Vector2 size, in HitInfoFilter filter, SizeReferenceType sizeReferenceType=SizeReferenceType.Bottom)
 Checks if the body fits in place. If so, it automatically changes the size of the body. More...
 
bool CheckAndSetSize (Vector2 size, SizeReferenceType sizeReferenceType=SizeReferenceType.Bottom)
 Checks if the body fits in place. If so, it automatically changes the size of the body. More...
 
bool CheckAndInterpolateSize (Vector2 targetSize, float lerpFactor, in HitInfoFilter filter, SizeReferenceType sizeReferenceType=SizeReferenceType.Bottom)
 Performs an overlap test, and if the result is valid, it interpolates the size of the body from the current value to a given target value. More...
 
bool CheckAndInterpolateSize (Vector2 targetSize, float lerpFactor, SizeReferenceType sizeReferenceType=SizeReferenceType.Bottom)
 Interpolates (Lerps) the height of the body to a target height. More...
 
bool CheckAndInterpolateHeight (float targetHeight, float lerpFactor, SizeReferenceType sizeReferenceType)
 Interpolates (Lerps) the height of the body to a target height. More...
 
bool CheckAndInterpolateHeight (float targetHeight, float lerpFactor, in HitInfoFilter filter, SizeReferenceType sizeReferenceType=SizeReferenceType.Bottom)
 Interpolates (Lerps) the height of the body to a target height. More...
 
void SweepAndTeleport (Vector3 destination)
 Sweeps the body from its current position (CharacterActor.Position) towards the desired destination using the "collide and slide" algorithm. At the end, the character will be moved to a valid position. Triggers and one way platforms will be ignored.
 
void SweepAndTeleport (Vector3 destination, in HitInfoFilter filter)
 Sweeps the body from its current position (CharacterActor.Position) towards the desired destination using the "collide and slide" algorithm. At the end, the character will be moved to a valid position.
 
void ForceGrounded ()
 Forces the character to be grounded (isGrounded = true) if possible. The detection distance includes the step down distance.
 
Vector3 GetGroundSlopeNormal (CollisionInfo collisionInfo)
 
void ForceNotGrounded (int ignoreGroundContactFrames=3)
 Forces the character to abandon the grounded state (isGrounded = false). More...
 
bool CheckOneWayPlatformLayerMask (int layer)
 
bool CheckOneWayPlatformLayerMask (GameObject gameObject)
 
bool CheckOneWayPlatformLayerMask (CollisionInfo collisionInfo)
 
bool CheckOneWayPlatformCollision (Vector3 contactPoint, Vector3 characterPosition)
 
- Public Member Functions inherited from Lightbug.CharacterControllerPro.Core.PhysicsActor
void Move (Vector3 position)
 Sets the rigidbody velocity based on a target position. The same can be achieved by setting the velocity value manually.
 
void Teleport (Vector3 position)
 Sets the teleportation position. The character will move/rotate internally using its own internal logic.
 
void Teleport (Transform reference)
 Sets the teleportation position and rotation using an external Transform reference. The character will move/rotate internally using its own internal logic.
 
void Teleport (Vector3 position, Quaternion rotation)
 Sets the teleportation position and rotation. The character will move/rotate internally using its own internal logic.
 
virtual void SetRotation (Vector3 forward, Vector3 up)
 Sets a rotation based on "forward" and "up". This is equivalent to Quaternion.LookRotation. More...
 
virtual void RotateAround (Quaternion deltaRotation, Vector3 pivot)
 Rotates the character by doing yaw rotation (around its "up" axis). More...
 
virtual void SetYaw (Vector3 forward)
 Rotates the character by doing yaw rotation (around its "up" axis) based on a given "forward" vector. More...
 
void SetYaw (float angle)
 Rotates the character by doing yaw rotation (around its "up" axis). More...
 
virtual void RotateYaw (float angle)
 Rotates the character by doing yaw rotation (around its "up" axis). More...
 
virtual void RotateYaw (float angle, Vector3 pivot)
 Rotates the character by doing yaw rotation (around its "up" axis). More...
 
virtual void RotatePitch (float angle)
 Rotates the character by doing pitch rotation (around its "right" axis). More...
 
virtual void RotatePitch (float angle, Vector3 pivot)
 Rotates the character by doing pitch rotation (around its "right" axis). More...
 
virtual void RotateRoll (float angle)
 Rotates the character by doing roll rotation (around its "forward" axis). More...
 
virtual void RotateRoll (float angle, Vector3 pivot)
 Rotates the character by doing roll rotation (around its "forward" axis). More...
 
virtual void TurnAround ()
 Rotates the character by performing 180 degrees of yaw rotation (around its vertical axis). Also, interpolation (rotation) gets automatically reset just to prevent weird visual artifacts. More...
 
void InitializeAnimation ()
 Configures all the animation-related components based on a given Animator component. The Animator provides root motion data along
 
void SetAnimator (Animator animator)
 
void ResetIKWeights ()
 
void SyncBody ()
 
void InterpolateBody ()
 
void UpdateInterpolationTargets ()
 
void ResetInterpolationPosition ()
 Prevents the body from getting its position interpolated during one physics update.
 
void ResetInterpolationRotation ()
 Prevents the body from getting its rotation interpolated during one physics update.
 
void ResetInterpolation ()
 Prevents the body from getting interpolated during one physics update.
 
bool IsAnimatorValid ()
 Checks if the Animator component associated with the character is valid or not. An Animator is valid if it is active and its internal references are not null. More...
 
virtual void OnValidate ()
 

Public Attributes

LayerMask oneWayPlatformsLayerMask = 0
 
float oneWayPlatformsValidArc = 175f
 
float slopeLimit = 55f
 
LayerMask stableLayerMask = -1
 
bool allowCharactersAsStableSurfaces = true
 
bool preventUnstableClimbing = true
 
bool preventBadSteps = true
 
float stepUpDistance = 0.5f
 
float stepDownDistance = 0.5f
 
bool alwaysNotGrounded = false
 
bool forceGroundedAtStart = true
 
bool useGroundTrigger = true
 
bool edgeCompensation = false
 
bool useStableEdgeWhenLanding = true
 
bool detectGroundWhileAscending = false
 
bool supportDynamicGround = true
 
LayerMask dynamicGroundLayerMask = -1
 
bool rotateForwardDirection = true
 
float maxGroundVelocityChange = 30f
 
float inheritedGroundPlanarVelocityThreshold = 2f
 
float inheritedGroundPlanarVelocityMultiplier = 1f
 
float inheritedGroundVerticalVelocityThreshold = 2f
 
float inheritedGroundVerticalVelocityMultiplier = 1f
 
bool slideOnWalls = true
 
CharacterVelocityMode stablePostSimulationVelocity = CharacterVelocityMode.UsePostSimulationVelocity
 
CharacterVelocityMode unstablePostSimulationVelocity = CharacterVelocityMode.UsePostSimulationVelocity
 
bool constraintRotation = true
 
Transform upDirectionReference = null
 
VerticalAlignmentSettings.VerticalReferenceMode upDirectionReferenceMode = VerticalAlignmentSettings.VerticalReferenceMode.Away
 
Vector3 constraintUpDirection = Vector3.up
 
bool canPushDynamicRigidbodies = true
 
LayerMask pushableRigidbodyLayerMask = -1
 
bool applyWeightToGround = true
 
LayerMask applyWeightLayerMask = -1
 
float weightGravity = CharacterConstants.DefaultGravity
 
- Public Attributes inherited from Lightbug.CharacterControllerPro.Core.PhysicsActor
bool interpolateActor = true
 
bool useContinuousCollisionDetection = true
 
bool UseRootMotion = false
 
bool UpdateRootPosition = true
 
RootMotionVelocityType rootMotionVelocityType = RootMotionVelocityType.SetVelocity
 
bool UpdateRootRotation = true
 
RootMotionRotationType rootMotionRotationType = RootMotionRotationType.AddRotation
 

Protected Member Functions

override void Awake ()
 
override void Start ()
 
override void OnEnable ()
 
override void OnDisable ()
 
virtual void ApplyWeight (Vector3 contactPoint)
 Applies a force at the ground contact point, in the direction of the weight (mass times gravity).
 
override void PreSimulationUpdate (float dt)
 
override void PostSimulationUpdate (float dt)
 
bool RemovePenetration (ref Vector3 position)
 
override void UpdateDynamicRootMotionPosition ()
 
void StableCollideAndSlide (ref Vector3 position, Vector3 displacement, bool useFullBody)
 
void UnstableCollideAndSlide (ref Vector3 position, Vector3 displacement, float dt)
 
bool CanPerformUnstableGroundDetection (in HitInfo hitInfo)
 
- Protected Member Functions inherited from Lightbug.CharacterControllerPro.Core.PhysicsActor
virtual void PreSimulationUpdate (float dt)
 
virtual void PostSimulationUpdate (float dt)
 
virtual void UpdateKinematicRootMotionPosition ()
 
virtual void UpdateKinematicRootMotionRotation ()
 
virtual void UpdateDynamicRootMotionPosition ()
 
virtual void UpdateDynamicRootMotionRotation ()
 
virtual void Awake ()
 
virtual void OnEnable ()
 
virtual void OnDisable ()
 
virtual void Start ()
 

Protected Attributes

CharacterCollisionInfo characterCollisionInfo = new CharacterCollisionInfo()
 

Properties

float StepOffset [get]
 
override RigidbodyComponent RigidbodyComponent [get]
 Gets the RigidbodyComponent component associated with the character.
 
ColliderComponent ColliderComponent [get]
 Gets the ColliderComponent component associated with the character.
 
PhysicsComponent PhysicsComponent [get]
 Gets the physics component from the character.
 
CharacterBody CharacterBody [get]
 Gets the CharacterBody component associated with this character actor.
 
CharacterActorState CurrentState [get]
 Returns the current character actor state. This enum variable contains the information about the grounded and stable state, all in one.
 
CharacterActorState PreviousState [get]
 Returns the character actor state from the previous frame.
 
LayerMask ObstaclesLayerMask [get]
 
LayerMask ObstaclesWithoutOWPLayerMask [get]
 
bool IsOnEdge [get]
 Returns true if the character is standing on an edge.
 
float EdgeAngle [get]
 Returns the angle between the both sides of the edge.
 
bool IsGrounded [get]
 Gets the grounded state, true if the ground object is not null, false otherwise.
 
float GroundSlopeAngle [get]
 Gets the angle between the up vector and the stable normal.
 
Vector3 GroundContactPoint [get]
 Gets the contact point obtained directly from the ground test (sphere cast).
 
Vector3 GroundContactNormal [get]
 Gets the normal vector obtained directly from the ground test (sphere cast).
 
Vector3 GroundStableNormal [get]
 Gets the normal vector used to determine stability. This may or may not be the normal obtained from the ground test.
 
GameObject GroundObject [get]
 Gets the GameObject component of the current ground.
 
Transform GroundTransform [get]
 Gets the Transform component of the current ground.
 
Collider2D GroundCollider2D [get]
 Gets the Collider2D component of the current ground.
 
Collider GroundCollider3D [get]
 Gets the Collider3D component of the current ground.
 
Rigidbody2D GroundRigidbody2D [get]
 Gets the Rigidbody2D component of the current ground.
 
Rigidbody GroundRigidbody3D [get]
 Gets the Rigidbody component of the current ground.
 
bool WallCollision [get]
 Gets the wall collision flag, true if the character hit a wall, false otherwise.
 
float WallAngle [get]
 Gets the angle between the contact normal (wall collision) and the Up direction. More...
 
Contact WallContact [get]
 Gets the current contact (wall collision).
 
bool HeadCollision [get]
 Gets the head collision flag, true if the character hits something with its head, false otherwise.
 
float HeadAngle [get]
 Gets the angle between the contact normal (head collision) and the Up direction.
 
Contact HeadContact [get]
 Gets the current contact (head collision).
 
bool IsStable [get]
 Gets the current stability state of the character. Stability is equal to "grounded + slope angle <= slope limit".
 
bool IsOnUnstableGround [get]
 Returns true if the character is grounded onto an unstable ground, false otherwise.
 
bool WasGrounded [get]
 Gets the previous grounded state.
 
bool WasStable [get]
 Gets the previous stability state.
 
bool HasBecomeGrounded [get]
 A property that indicates if the character has become grounded during the previous physics update.
 
bool HasBecomeStable [get]
 A property that indicates if the character has become stable during the previous physics update.
 
bool HasBecomeNotGrounded [get]
 A property that indicates if the character has abandoned the grounded state during the previous physics update.
 
bool HasBecomeUnstable [get]
 A property that indicates if the character has become unstable during the previous physics update.
 
RigidbodyComponent GroundRigidbodyComponent [get]
 Gets the RigidbodyComponent component from the ground.
 
Vector3 GroundPosition [get]
 Gets the ground rigidbody position.
 
Quaternion GroundRotation [get]
 Gets the ground rigidbody rotation.
 
bool IsGroundARigidbody [get]
 Returns true if the current ground is a Rigidbody (2D or 3D), false otherwise.
 
bool IsGroundAKinematicRigidbody [get]
 Returns true if the current ground is a kinematic Rigidbody (2D or 3D), false otherwise.
 
CharacterCollisionInfo CharacterCollisionInfo [get]
 Gets a structure with all the information regarding character collisions. Most of the character properties (e.g. IsGrounded, IsStable, GroundObject, and so on) can be obtained from this structure.
 
float GroundedTime [get]
 
float NotGroundedTime [get]
 
float StableElapsedTime [get]
 
float UnstableElapsedTime [get]
 
Vector2 BodySize [get]
 Gets the current body size (width and height).
 
Vector2 DefaultBodySize [get]
 Gets the current body size (width and height).
 
Vector3 StableVelocity [get, set]
 Gets/Sets the rigidbody velocity projected onto a plane formed by its up direction.
 
Vector3 LastGroundedVelocity [get]
 
Vector3 Center [get]
 Gets the center of the collision shape.
 
Vector3 Top [get]
 Gets the center of the collision shape.
 
Vector3 Bottom [get]
 Gets the center of the collision shape.
 
Vector3 TopCenter [get]
 Gets the center of the collision shape.
 
Vector3 BottomCenter [get]
 Gets the center of the collision shape.
 
Vector3 OffsettedBottomCenter [get]
 Gets the center of the collision shape.
 
CharacterCollisions CharacterCollisions [get]
 
List< ContactContacts [get]
 Gets a list with all the current contacts.
 
Trigger CurrentTrigger [get]
 Gets the most recent trigger.
 
List< TriggerTriggers [get]
 Gets a list with all the triggers.
 
Vector3 InputVelocity [get]
 Gets the character velocity vector (Velocity) assigned prior to the FixedUpdate call. This is also known as the "input" velocity, since it is the value the user has specified.
 
Vector3 LocalInputVelocity [get]
 Gets/Sets the rigidbody local velocity.
 
Vector3 PreSimulationVelocity [get]
 Gets a velocity vector which is the input velocity modified, based on the character actor internal rules (step up, slope limit, etc). This velocity corresponds to the one used by the physics simulation.
 
Vector3 PostSimulationVelocity [get]
 Gets the character velocity as the result of the Physics simulation.
 
Vector3 ExternalVelocity [get]
 Gets the difference between the post-simulation velocity (after the physics simulation) and the pre-simulation velocity (just before the physics simulation). This value is useful to detect any external response due to the physics simulation, such as hits coming from other rigidbodies.
 
List< ContactWallContacts = new List<Contact>(10) [get]
 Returns a lits of all the contacts involved with wall collision events.
 
List< ContactHeadContacts = new List<Contact>(10) [get]
 Returns a lits of all the contacts involved with head collision events.
 
List< ContactGroundContacts = new List<Contact>(10) [get]
 Returns a lits of all the contacts involved with head collision events.
 
Vector3 GroundVelocity [get]
 Gets the velocity of the ground (rigidbody).
 
Vector3 PreviousGroundVelocity [get]
 Gets the previous velocity of the ground (rigidbody).
 
Vector3 GroundDeltaVelocity [get]
 The ground change in velocity (current velocity - previous velocity).
 
Vector3 GroundAcceleration [get]
 The ground acceleration (GroundDeltaVelocity / dt).
 
bool IsGroundAscending [get]
 Returns true if the ground vertical displacement (moving ground) is positive.
 
Vector3 GroundProbingDisplacement [get]
 The last vertical displacement calculated by the ground probabing algorithm (PostGroundProbingPosition - PreGroundProbingPosition).
 
Vector3 PreGroundProbingPosition [get]
 The last rigidbody position prior to the ground probing algorithm.
 
Vector3 PostGroundProbingPosition [get]
 The last rigidbody position after the ground probing algorithm.
 
bool IsGroundAOneWayPlatform [get]
 Returns true if the current ground layer is considered as a one way platform.
 
bool CanEnterGroundedState [get]
 
GameObject PredictedGround [get]
 Gets the object below the character (only valid if the character is falling). The maximum prediction distance is defined by the constant "GroundPredictionDistance".
 
float PredictedGroundDistance [get]
 Gets the distance to the "PredictedGround".
 
- Properties inherited from Lightbug.CharacterControllerPro.Core.PhysicsActor
abstract RigidbodyComponent RigidbodyComponent [get]
 Gets the RigidbodyComponent component associated with the character.
 
Animator Animator [get]
 Gets the Animator component associated with the actor.
 
Vector3 Velocity [get, set]
 Gets/Sets the rigidbody velocity.
 
Vector3 PlanarVelocity [get, set]
 Gets/Sets the rigidbody velocity projected onto a plane formed by its up direction.
 
Vector3 VerticalVelocity [get, set]
 Gets/Sets the rigidbody velocity projected onto its up direction.
 
Vector3 LocalVelocity [get, set]
 Gets/Sets the rigidbody local velocity.
 
Vector3 LocalPlanarVelocity [get, set]
 Gets/Sets the rigidbody local planar velocity.
 
Vector3 LocalVerticalVelocity [get, set]
 Gets/Sets the rigidbody local vertical velocity.
 
bool IsFalling [get]
 Returns true if the character local vertical velocity is less than zero.
 
bool IsAscending [get]
 Returns true if the character local vertical velocity is greater than zero.
 
bool Is2D [get]
 Gets the CharacterBody component associated with this character actor.
 
Vector3 Position [get, set]
 Gets/Sets the current rigidbody position. This action will produce an "interpolation reset", meaning that (visually) the object will move instantly to the target.
 
Quaternion Rotation [get, set]
 Gets/Sets the current rigidbody rotation. This action will produce an "interpolation reset", meaning that (visually) the object will rotate instantly to the target.
 
bool IsKinematic [get, set]
 
virtual Vector3 Up [get, set]
 Gets the current up direction based on the rigidbody rotation (not necessarily transform.up).
 
virtual Vector3 Forward [get, set]
 Gets/Sets the current forward direction based on the rigidbody rotation (not necessarily transform.forward).
 
virtual Vector3 Right [get, set]
 Gets the current up direction based on the rigidbody rotation (not necessarily transform.right)
 

Events

System.Action< ContactOnHeadHit
 This event is called when the character hits its head (not grounded). More...
 
System.Action< ContactOnWallHit
 This event is called everytime the character is blocked by an unallowed geometry, this could be a wall or a steep slope (depending on the "slopeLimit" value). More...
 
System.Action< Vector3 > OnGroundedStateEnter
 This event is called when the character enters the grounded state. More...
 
System.Action OnGroundedStateExit
 This event is called when the character exits the grounded state.
 
System.Action OnNewGroundEnter
 This event is called when the character make contact with a new ground (object).
 
System.Action< Vector3 > OnStableStateEnter
 This event is called when the character becomes stable. More...
 
System.Action OnStableStateExit
 This event is called when the character becomes unstable. More...
 
- Events inherited from Lightbug.CharacterControllerPro.Core.PhysicsActor
System.Action< float > OnPreSimulation
 This event is called prior to the physics simulation.
 
System.Action< float > OnPostSimulation
 This event is called after the physics simulation.
 
System.Action< Vector3, Quaternion > OnTeleport
 
System.Action OnAnimatorMoveEvent
 
System.Action< int > OnAnimatorIKEvent
 

Detailed Description

This class represents a character actor. It contains all the character information, collision flags, collision events, and so on. It also responsible for the execution order of everything related to the character, such as movement, rotation, teleportation, rigidbodies interactions, body size, etc. Since the character can be 2D or 3D, this abstract class must be implemented in the two formats, one for 2D and one for 3D.

Member Function Documentation

◆ Awake()

override void Lightbug.CharacterControllerPro.Core.CharacterActor.Awake ( )
inlineprotectedvirtual

◆ CheckAndInterpolateHeight() [1/2]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckAndInterpolateHeight ( float  targetHeight,
float  lerpFactor,
in HitInfoFilter  filter,
SizeReferenceType  sizeReferenceType = SizeReferenceType.Bottom 
)

Interpolates (Lerps) the height of the body to a target height.

Parameters
targetHeightThe desired height.
lerpFactorHow fast the interpolation is going to be applied.
sizeReferenceTypeAnchor point used when changing the size.
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckAndInterpolateHeight() [2/2]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckAndInterpolateHeight ( float  targetHeight,
float  lerpFactor,
SizeReferenceType  sizeReferenceType 
)

Interpolates (Lerps) the height of the body to a target height.

Parameters
targetHeightThe desired height.
lerpFactorHow fast the interpolation is going to be applied.
sizeReferenceTypeAnchor point used when changing the size.
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckAndInterpolateSize() [1/2]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckAndInterpolateSize ( Vector2  targetSize,
float  lerpFactor,
in HitInfoFilter  filter,
SizeReferenceType  sizeReferenceType = SizeReferenceType.Bottom 
)
inline

Performs an overlap test, and if the result is valid, it interpolates the size of the body from the current value to a given target value.

Parameters
targetSize
lerpFactorHow fast the interpolation is going to be applied.
filterFilter settings
sizeReferenceTypeAnchor point used when changing the size.
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckAndInterpolateSize() [2/2]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckAndInterpolateSize ( Vector2  targetSize,
float  lerpFactor,
SizeReferenceType  sizeReferenceType = SizeReferenceType.Bottom 
)
inline

Interpolates (Lerps) the height of the body to a target height.

Parameters
targetHeightThe desired height.
lerpFactorHow fast the interpolation is going to be applied.
sizeReferenceTypeAnchor point used when changing the size.
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckAndSetSize() [1/4]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckAndSetSize ( Vector2  size,
in HitInfoFilter  filter,
SizeReferenceType  sizeReferenceType = SizeReferenceType.Bottom 
)

Checks if the body fits in place. If so, it automatically changes the size of the body.

Parameters
sizeA Vector2 representing the desired width (x) and height (y) values.
sizeReferenceTypeAnchor point used when changing the size.
filter
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckAndSetSize() [2/4]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckAndSetSize ( Vector2  size,
SizeReferenceType  sizeReferenceType = SizeReferenceType.Bottom 
)
inline

Checks if the body fits in place. If so, it automatically changes the size of the body.

Parameters
sizeA Vector2 representing the desired width (x) and height (y) values.
sizeReferenceTypeAnchor point used when changing the size.
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckAndSetSize() [3/4]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckAndSetSize ( Vector3  position,
Vector2  size,
in HitInfoFilter  filter,
SizeReferenceType  sizeReferenceType = SizeReferenceType.Bottom 
)
inline

Checks if the body fits in place. If so, it automatically changes the size of the body.

Parameters
positionThe position of the character.
sizeA Vector2 representing the desired width (x) and height (y) values.
sizeReferenceTypeAnchor point used when changing the size.
filter
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckAndSetSize() [4/4]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckAndSetSize ( Vector3  position,
Vector2  size,
SizeReferenceType  sizeReferenceType = SizeReferenceType.Bottom 
)
inline

Checks if the body fits in place. If so, it automatically changes the size of the body.

Parameters
positionThe position of the character.
sizeA Vector2 representing the desired width (x) and height (y) values.
sizeReferenceTypeAnchor point used when changing the size.
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckSize() [1/4]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckSize ( Vector2  size)
inline

Checks if the body fits in place by performing an overlap.

Parameters
sizeA Vector2 representing the desired width (x) and height (y).
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckSize() [2/4]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckSize ( Vector2  size,
in HitInfoFilter  filter 
)

Checks if the body fits in place by performing an overlap.

Parameters
sizeA Vector2 representing the desired width (x) and height (y).
filterFilter used by the overlap function.
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckSize() [3/4]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckSize ( Vector3  position,
Vector2  size 
)
inline

Checks if the body fits in place by performing an overlap.

Parameters
positionOverlap position.
sizeA Vector2 representing the desired width (x) and height (y).
Returns
True if the overlap doesn't detect any obstacle.

◆ CheckSize() [4/4]

bool Lightbug.CharacterControllerPro.Core.CharacterActor.CheckSize ( Vector3  position,
Vector2  size,
in HitInfoFilter  filter 
)

Checks if the body fits in place by performing an overlap.

Parameters
positionOverlap position.
sizeA Vector2 representing the desired width (x) and height (y).
filterFilter used by the overlap function.
Returns
True if the overlap doesn't detect any obstacle.

◆ ForceNotGrounded()

void Lightbug.CharacterControllerPro.Core.CharacterActor.ForceNotGrounded ( int  ignoreGroundContactFrames = 3)
inline

Forces the character to abandon the grounded state (isGrounded = false).

TIP: This is useful when making the character jump.

Parameters
ignoreGroundContactFramesThe number of FixedUpdate frames to consume in order to prevent the character to re-enter grounded state right after a ForceNotGrounded call.

◆ OnDisable()

override void Lightbug.CharacterControllerPro.Core.CharacterActor.OnDisable ( )
inlineprotectedvirtual

◆ OnEnable()

override void Lightbug.CharacterControllerPro.Core.CharacterActor.OnEnable ( )
inlineprotectedvirtual

◆ OnValidate()

override void Lightbug.CharacterControllerPro.Core.CharacterActor.OnValidate ( )
inlinevirtual

◆ PostSimulationUpdate()

override void Lightbug.CharacterControllerPro.Core.CharacterActor.PostSimulationUpdate ( float  dt)
inlineprotectedvirtual

◆ PreSimulationUpdate()

override void Lightbug.CharacterControllerPro.Core.CharacterActor.PreSimulationUpdate ( float  dt)
inlineprotectedvirtual

◆ SetSize()

void Lightbug.CharacterControllerPro.Core.CharacterActor.SetSize ( Vector2  size,
SizeReferenceType  sizeReferenceType 
)
inline

Changes the body size of the actor. Additionaly, an overlap test can be performed beforehand in order to check if the character will fit or not. If the test failed (overlap detected), changes won't be applied.

Parameters
sizeA Vector2 representing the desired width (x) and height (y).
sizeReferenceTypeAnchor point used when changing the size.

◆ Start()

override void Lightbug.CharacterControllerPro.Core.CharacterActor.Start ( )
inlineprotectedvirtual

◆ UpdateDynamicRootMotionPosition()

override void Lightbug.CharacterControllerPro.Core.CharacterActor.UpdateDynamicRootMotionPosition ( )
inlineprotectedvirtual

Property Documentation

◆ WallAngle

float Lightbug.CharacterControllerPro.Core.CharacterActor.WallAngle
get

Gets the angle between the contact normal (wall collision) and the Up direction.


Event Documentation

◆ OnGroundedStateEnter

System.Action<Vector3> Lightbug.CharacterControllerPro.Core.CharacterActor.OnGroundedStateEnter

This event is called when the character enters the grounded state.

The local linear velocity is passed as an argument.

◆ OnHeadHit

System.Action<Contact> Lightbug.CharacterControllerPro.Core.CharacterActor.OnHeadHit

This event is called when the character hits its head (not grounded).

The related collision information struct is passed as an argument.

◆ OnStableStateEnter

System.Action<Vector3> Lightbug.CharacterControllerPro.Core.CharacterActor.OnStableStateEnter

This event is called when the character becomes stable.

The local linear velocity is passed as an argument.

◆ OnStableStateExit

System.Action Lightbug.CharacterControllerPro.Core.CharacterActor.OnStableStateExit

This event is called when the character becomes unstable.

The local linear velocity is passed as an argument.

◆ OnWallHit

System.Action<Contact> Lightbug.CharacterControllerPro.Core.CharacterActor.OnWallHit

This event is called everytime the character is blocked by an unallowed geometry, this could be a wall or a steep slope (depending on the "slopeLimit" value).

The related collision information struct is passed as an argument.


The documentation for this class was generated from the following file: