TopDown Engine
v3.6
|
A controller, initially adapted from Unity's CharacterMotor.js, to add on top of Unity's native CharacterController, that will handle More...
Public Types | |
enum | GroundedComputationModes { GroundedComputationModes.Simple, GroundedComputationModes.Advanced } |
the possible modes to compute grounded state. Simple should only be used if your ground is even and flat More... | |
enum | UpdateModes { UpdateModes.Update, UpdateModes.FixedUpdate } |
the different possible update modes More... | |
enum | VelocityTransferOnJump { VelocityTransferOnJump.NoTransfer, VelocityTransferOnJump.InitialVelocity, VelocityTransferOnJump.FloorVelocity, VelocityTransferOnJump.Relative } |
the possible ways to transfer velocity on jump More... | |
Public Member Functions | |
virtual bool | IsSliding () |
whether or not the character is sliding down a steep slope More... | |
virtual bool | CollidingAbove () |
whether or not the character is colliding above More... | |
virtual bool | TooSteep () |
whether or not the current surface is too steep or not More... | |
virtual void | DetachFromGround () |
Forces the controller to detach from the ground More... | |
virtual void | DetachFromMovingPlatform () |
override bool | CanGoBackToOriginalSize () |
Determines whether this instance can go back to original size. More... | |
override void | ResizeColliderHeight (float newHeight, bool translateCenter=false) |
Resizes the collider to the new size set in parameters More... | |
override void | ResetColliderSize () |
Returns the collider to its initial size More... | |
virtual bool | IsGroundedTest () |
Whether or not the character is grounded More... | |
override void | CollisionsOn () |
Enables the collider More... | |
override void | CollisionsOff () |
Disables collider More... | |
override void | DetectObstacles (float distance, Vector3 offset) |
Performs a cardinal collision check and stores collision objects informations More... | |
override void | AddForce (Vector3 movement) |
Adds a force of the specified direction and magnitude to the character More... | |
override void | Impact (Vector3 direction, float force) |
Applies an impact to the character of the specified direction and force More... | |
override void | SetMovement (Vector3 movement) |
Sets the character's current input direction and magnitude More... | |
override void | SetKinematic (bool state) |
Turns this character's rigidbody kinematic or not More... | |
override void | MovePosition (Vector3 newPosition) |
Moves this character to the specified position while trying to avoid obstacles More... | |
override void | Reset () |
On reset, we reset vectors and transforms More... | |
Public Member Functions inherited from MoreMountains.TopDownEngine.TopDownController | |
virtual void | SetGravityActive (bool status) |
Sets gravity active or inactive More... | |
Public Attributes | |
Vector3 | InputMoveDirection = Vector3.zero |
the current input sent to this character More... | |
UpdateModes | UpdateMode = UpdateModes.FixedUpdate |
whether the movement computation should occur at Update or FixedUpdate. FixedUpdate is the recommended choice. More... | |
VelocityTransferOnJump | VelocityTransferMethod = VelocityTransferOnJump.FloorVelocity |
how the velocity should be affected when jumping from a moving ground More... | |
LayerMask | ObstaclesLayerMask = LayerManager.ObstaclesLayerMask |
the layer to consider as obstacles (will prevent movement) More... | |
float | GroundedRaycastLength = 5f |
the length of the raycasts to cast downwards More... | |
float | MinimumGroundedDistance = 0.2f |
the distance to the ground beyond which the character isn't considered grounded anymore More... | |
GroundedComputationModes | GroundedComputationMode = GroundedComputationModes.Advanced |
the selected modes to compute grounded state. Simple should only be used if your ground is even and flat More... | |
float | GroundNormalHeightThreshold = 0.2f |
a threshold against which to check when going over steps. Adjust that value if your character has issues going over small steps More... | |
float | ImpactFalloff = 5f |
the speed at which external forces get lerped to zero More... | |
float | MaximumFallSpeed = 20.0f |
the maximum vertical velocity the character can have while falling More... | |
AnimationCurve | SlopeSpeedMultiplier = new AnimationCurve(new Keyframe(-90, 1), new Keyframe(0, 1), new Keyframe(90, 0)) |
the factor by which to multiply the speed while walking on a slope. x is the angle, y is the factor More... | |
Vector3 | GroundNormal = Vector3.zero |
the current surface normal vector More... | |
bool | SlideOnSteepSurfaces = true |
whether or not the character should slide while standing on steep surfaces More... | |
float | SlidingSpeed = 15f |
the speed at which the character should slide More... | |
float | SlidingSpeedControl = 0.4f |
the control the player has on the speed while sliding down More... | |
float | SlidingDirectionControl = 1f |
the control the player has on the direction while sliding down More... | |
Public Attributes inherited from MoreMountains.TopDownEngine.TopDownController | |
float | Gravity = 40f |
the current gravity to apply to our character (positive goes down, negative goes up, higher value, higher acceleration) More... | |
bool | GravityActive = true |
whether or not the gravity is currently being applied to this character More... | |
float | CrouchedRaycastLengthMultiplier = 1f |
by default, the length of the raycasts used to get back to normal size will be auto generated based on your character's normal/standing height, but here you can specify a different value More... | |
bool | PerformCardinalObstacleRaycastDetection = false |
if this is true, extra raycasts will be cast on all 4 sides to detect obstacles and feed the CollidingWithCardinalObstacle bool, only useful when working with grid movement, or if you need that info for some reason More... | |
Vector3 | Speed |
the current speed of the character More... | |
Vector3 | Velocity |
the current velocity More... | |
Vector3 | VelocityLastFrame |
the velocity of the character last frame More... | |
Vector3 | Acceleration |
the current acceleration More... | |
bool | Grounded |
whether or not the character is grounded More... | |
bool | JustGotGrounded |
whether or not the character got grounded this frame More... | |
Vector3 | CurrentMovement |
the current movement of the character More... | |
Vector3 | CurrentDirection |
the direction the character is going in More... | |
float | Friction |
the current friction More... | |
Vector3 | AddedForce |
the current added force, to be added to the character's movement More... | |
bool | FreeMovement = true |
whether or not the character is in free movement mode or not More... | |
Protected Member Functions | |
override void | Awake () |
On awake we store our various components for future use More... | |
override void | LateUpdate () |
On late update we apply any impact we have in store, and store our velocity for use next frame More... | |
override void | Update () |
On Update we process our Update computations if UpdateMode is set to Update More... | |
override void | FixedUpdate () |
On FixedUpdate we process our Update computations if UpdateMode is set to FixedUpdate More... | |
virtual void | ProcessUpdate () |
Computes the new velocity and moves the character More... | |
virtual void | AddInput () |
Determines the new velocity based on the slope we're on and the input More... | |
virtual void | AddGravity () |
Adds the gravity to the new velocity and any AddedForce we may have More... | |
virtual void | MoveWithPlatform () |
Moves and rotates the character controller to follow any moving platform we may be standing on More... | |
virtual void | ComputeVelocityDelta () |
Computes the motion vector to apply to the character controller More... | |
virtual void | MoveCharacterController () |
Moves the character controller by the computed _motion More... | |
virtual void | DetectNewMovingPlatform () |
Detects any moving platform we may be standing on More... | |
virtual void | ComputeNewVelocity () |
Determines the new Velocity value based on our position and our position last frame More... | |
virtual void | HandleGroundContact () |
We handle ground contact, velocity transfer and moving platforms More... | |
override void | DetermineDirection () |
Determines the direction based on the current movement More... | |
override void | HandleFriction () |
Handles friction with ground surfaces, coming soon More... | |
virtual void | ManualControllerColliderHit () |
This method compensates for the regular OnControllerColliderHit, which unfortunately generates a lot of garbage. To do so, it casts a ray downwards to get our ground normal, and a ray in the current movement direction to (potentially) push rigidbodies More... | |
virtual void | HandleAdvancedGroundDetection () |
virtual void | CastRayDownwards () |
Casts a ray downwards and adjusts distances if needed More... | |
float | AdjustDistance (float distance) |
Returns the real distance between the extremity of the character and the ground More... | |
virtual void | OnTriggerEnter (Collider other) |
When triggering with something else, we check if it's a moving platform and we push ourselves if needed More... | |
virtual void | GetMovingPlatformVelocity () |
Gets the current moving platform's velocity More... | |
virtual IEnumerator | SubstractNewPlatformVelocity () |
Computes the relative velocity More... | |
virtual bool | ShouldMoveWithPlatformThisFrame () |
Whether or not our character should move with the moving platform this frame More... | |
override void | CheckIfGrounded () |
Grounded check More... | |
virtual void | ApplyImpact () |
Applies the stored impact to the character More... | |
Protected Member Functions inherited from MoreMountains.TopDownEngine.TopDownController | |
virtual void | ComputeSpeed () |
Computes the speed More... | |
Properties | |
override Vector3 | ColliderCenter [get] |
returns the center coordinate of the collider More... | |
override Vector3 | ColliderBottom [get] |
returns the bottom coordinate of the collider More... | |
override Vector3 | ColliderTop [get] |
returns the top coordinate of the collider More... | |
virtual bool | ExitedTooSteepSlopeThisFrame [get, set] |
whether or not the character just entered a slope/ground not too steep this frame More... | |
override bool | OnAMovingPlatform [get] |
whether or not the character is on a moving platform More... | |
override Vector3 | MovingPlatformSpeed [get] |
the speed of the moving platform More... | |
Properties inherited from MoreMountains.TopDownEngine.TopDownController | |
virtual Vector3 | ColliderCenter [get] |
the collider's center coordinates More... | |
virtual Vector3 | ColliderBottom [get] |
the collider's bottom coordinates More... | |
virtual Vector3 | ColliderTop [get] |
the collider's top coordinates More... | |
virtual GameObject | ObjectBelow [get, set] |
the object (if any) below our character More... | |
virtual SurfaceModifier | SurfaceModifierBelow [get, set] |
the surface modifier object below our character (if any) More... | |
virtual Vector3 | AppliedImpact [get] |
virtual bool | OnAMovingPlatform [get, set] |
whether or not the character is on a moving platform More... | |
virtual Vector3 | MovingPlatformSpeed [get, set] |
the speed of the moving platform More... | |
virtual GameObject | DetectedObstacleLeft [get, set] |
virtual GameObject | DetectedObstacleRight [get, set] |
virtual GameObject | DetectedObstacleUp [get, set] |
virtual GameObject | DetectedObstacleDown [get, set] |
virtual bool | CollidingWithCardinalObstacle [get, set] |
Additional Inherited Members | |
Static Protected Attributes inherited from MoreMountains.TopDownEngine.TopDownController | |
const float | _smallValue =0.0001f |
A controller, initially adapted from Unity's CharacterMotor.js, to add on top of Unity's native CharacterController, that will handle
|
virtual |
Adds a force of the specified direction and magnitude to the character
movement |
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
Adds the gravity to the new velocity and any AddedForce we may have
|
protectedvirtual |
Determines the new velocity based on the slope we're on and the input
|
protected |
Returns the real distance between the extremity of the character and the ground
distance |
|
protectedvirtual |
Applies the stored impact to the character
|
protectedvirtual |
On awake we store our various components for future use
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
virtual |
Determines whether this instance can go back to original size.
true
if this instance can go back to original size; otherwise, false
.Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
Casts a ray downwards and adjusts distances if needed
|
protectedvirtual |
Grounded check
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
virtual |
whether or not the character is colliding above
|
virtual |
Disables collider
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
virtual |
Enables the collider
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
Determines the new Velocity value based on our position and our position last frame
|
protectedvirtual |
Computes the motion vector to apply to the character controller
|
virtual |
Forces the controller to detach from the ground
|
virtual |
|
protectedvirtual |
Detects any moving platform we may be standing on
|
virtual |
Performs a cardinal collision check and stores collision objects informations
distance | |
offset |
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
Determines the direction based on the current movement
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
On FixedUpdate we process our Update computations if UpdateMode is set to FixedUpdate
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
Gets the current moving platform's velocity
|
protectedvirtual |
|
protectedvirtual |
Handles friction with ground surfaces, coming soon
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
We handle ground contact, velocity transfer and moving platforms
|
virtual |
Applies an impact to the character of the specified direction and force
direction | |
force |
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
virtual |
Whether or not the character is grounded
|
virtual |
whether or not the character is sliding down a steep slope
|
protectedvirtual |
On late update we apply any impact we have in store, and store our velocity for use next frame
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
This method compensates for the regular OnControllerColliderHit, which unfortunately generates a lot of garbage. To do so, it casts a ray downwards to get our ground normal, and a ray in the current movement direction to (potentially) push rigidbodies
|
protectedvirtual |
Moves the character controller by the computed _motion
|
virtual |
Moves this character to the specified position while trying to avoid obstacles
newPosition |
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
Moves and rotates the character controller to follow any moving platform we may be standing on
|
protectedvirtual |
When triggering with something else, we check if it's a moving platform and we push ourselves if needed
other |
|
protectedvirtual |
Computes the new velocity and moves the character
|
virtual |
On reset, we reset vectors and transforms
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
virtual |
Returns the collider to its initial size
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
virtual |
Resizes the collider to the new size set in parameters
newSize | New size. |
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
virtual |
Turns this character's rigidbody kinematic or not
state |
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
virtual |
Sets the character's current input direction and magnitude
movement |
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protectedvirtual |
Whether or not our character should move with the moving platform this frame
|
protectedvirtual |
Computes the relative velocity
|
virtual |
whether or not the current surface is too steep or not
|
protectedvirtual |
On Update we process our Update computations if UpdateMode is set to Update
Reimplemented from MoreMountains.TopDownEngine.TopDownController.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
GroundedComputationModes MoreMountains.TopDownEngine.TopDownController3D.GroundedComputationMode = GroundedComputationModes.Advanced |
the selected modes to compute grounded state. Simple should only be used if your ground is even and flat
float MoreMountains.TopDownEngine.TopDownController3D.GroundedRaycastLength = 5f |
the length of the raycasts to cast downwards
Vector3 MoreMountains.TopDownEngine.TopDownController3D.GroundNormal = Vector3.zero |
the current surface normal vector
float MoreMountains.TopDownEngine.TopDownController3D.GroundNormalHeightThreshold = 0.2f |
a threshold against which to check when going over steps. Adjust that value if your character has issues going over small steps
float MoreMountains.TopDownEngine.TopDownController3D.ImpactFalloff = 5f |
the speed at which external forces get lerped to zero
Vector3 MoreMountains.TopDownEngine.TopDownController3D.InputMoveDirection = Vector3.zero |
the current input sent to this character
float MoreMountains.TopDownEngine.TopDownController3D.MaximumFallSpeed = 20.0f |
the maximum vertical velocity the character can have while falling
float MoreMountains.TopDownEngine.TopDownController3D.MinimumGroundedDistance = 0.2f |
the distance to the ground beyond which the character isn't considered grounded anymore
LayerMask MoreMountains.TopDownEngine.TopDownController3D.ObstaclesLayerMask = LayerManager.ObstaclesLayerMask |
the layer to consider as obstacles (will prevent movement)
bool MoreMountains.TopDownEngine.TopDownController3D.SlideOnSteepSurfaces = true |
whether or not the character should slide while standing on steep surfaces
float MoreMountains.TopDownEngine.TopDownController3D.SlidingDirectionControl = 1f |
the control the player has on the direction while sliding down
float MoreMountains.TopDownEngine.TopDownController3D.SlidingSpeed = 15f |
the speed at which the character should slide
float MoreMountains.TopDownEngine.TopDownController3D.SlidingSpeedControl = 0.4f |
the control the player has on the speed while sliding down
AnimationCurve MoreMountains.TopDownEngine.TopDownController3D.SlopeSpeedMultiplier = new AnimationCurve(new Keyframe(-90, 1), new Keyframe(0, 1), new Keyframe(90, 0)) |
the factor by which to multiply the speed while walking on a slope. x is the angle, y is the factor
UpdateModes MoreMountains.TopDownEngine.TopDownController3D.UpdateMode = UpdateModes.FixedUpdate |
whether the movement computation should occur at Update or FixedUpdate. FixedUpdate is the recommended choice.
VelocityTransferOnJump MoreMountains.TopDownEngine.TopDownController3D.VelocityTransferMethod = VelocityTransferOnJump.FloorVelocity |
how the velocity should be affected when jumping from a moving ground
|
get |
returns the bottom coordinate of the collider
|
get |
returns the center coordinate of the collider
|
get |
returns the top coordinate of the collider
|
getset |
whether or not the character just entered a slope/ground not too steep this frame
|
get |
the speed of the moving platform
|
get |
whether or not the character is on a moving platform