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...
|
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) |
|
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 () |
|
|
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 |
|
bool | interpolateActor = true |
|
bool | useContinuousCollisionDetection = true |
|
bool | UseRootMotion = false |
|
bool | UpdateRootPosition = true |
|
RootMotionVelocityType | rootMotionVelocityType = RootMotionVelocityType.SetVelocity |
|
bool | UpdateRootRotation = true |
|
RootMotionRotationType | rootMotionRotationType = RootMotionRotationType.AddRotation |
|
|
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< Contact > | Contacts [get] |
| Gets a list with all the current contacts.
|
|
Trigger | CurrentTrigger [get] |
| Gets the most recent trigger.
|
|
List< Trigger > | Triggers [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< Contact > | WallContacts = new List<Contact>(10) [get] |
| Returns a lits of all the contacts involved with wall collision events.
|
|
List< Contact > | HeadContacts = new List<Contact>(10) [get] |
| Returns a lits of all the contacts involved with head collision events.
|
|
List< Contact > | GroundContacts = 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".
|
|
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)
|
|
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.