|
TopDown Engine v4.5
|
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 { Simple , Advanced } |
| the possible modes to compute grounded state. Simple should only be used if your ground is even and flat More... | |
| enum | UpdateModes { Update , FixedUpdate } |
| the different possible update modes More... | |
| enum | VelocityTransferOnJump { NoTransfer , InitialVelocity , FloorVelocity , 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 | |
| virtual bool | CollidingAbove () |
| whether or not the character is colliding above | |
| virtual bool | TooSteep () |
| whether or not the current surface is too steep or not | |
| virtual void | DetachFromGround () |
| Forces the controller to detach from the ground. | |
| virtual void | DetachFromMovingPlatform () |
| override bool | CanGoBackToOriginalSize () |
| Determines whether this instance can go back to original size. | |
| override void | ResizeColliderHeight (float newHeight, bool translateCenter=false) |
| Resizes the collider to the new size set in parameters. | |
| override void | ResetColliderSize () |
| Returns the collider to its initial size. | |
| virtual bool | IsGroundedTest () |
| Whether or not the character is grounded. | |
| override void | CollisionsOn () |
| Enables the collider. | |
| override void | CollisionsOff () |
| Disables collider. | |
| override void | DetectObstacles (float distance, Vector3 offset) |
| Performs a cardinal collision check and stores collision objects informations. | |
| override void | AddForce (Vector3 movement) |
| Adds a force of the specified direction and magnitude to the character. | |
| override void | Impact (Vector3 direction, float force) |
| Applies an impact to the character of the specified direction and force. | |
| override void | SetMovement (Vector3 movement) |
| Sets the character's current input direction and magnitude. | |
| override void | SetKinematic (bool state) |
| Turns this character's rigidbody kinematic or not. | |
| override void | MovePosition (Vector3 newPosition, bool targetTransform=false) |
| Moves this character to the specified position while trying to avoid obstacles. | |
| override void | Reset () |
| On reset, we reset vectors and transforms. | |
| Public Member Functions inherited from MoreMountains.TopDownEngine.TopDownController | |
| virtual void | SetGravityActive (bool status) |
| Sets gravity active or inactive. | |
Public Attributes | |
| Vector3 | InputMoveDirection = Vector3.zero |
| the current input sent to this character | |
| UpdateModes | UpdateMode = UpdateModes.FixedUpdate |
| whether the movement computation should occur at Update or FixedUpdate. FixedUpdate is the recommended choice. | |
| VelocityTransferOnJump | VelocityTransferMethod = VelocityTransferOnJump.FloorVelocity |
| how the velocity should be affected when jumping from a moving ground | |
| LayerMask | ObstaclesLayerMask = LayerManager.ObstaclesLayerMask |
| the layer to consider as obstacles (will prevent movement) | |
| float | GroundedRaycastLength = 5f |
| the length of the raycasts to cast downwards | |
| float | MinimumGroundedDistance = 0.2f |
| the distance to the ground beyond which the character isn't considered grounded anymore | |
| GroundedComputationModes | GroundedComputationMode = GroundedComputationModes.Advanced |
| the selected modes to compute grounded state. Simple should only be used if your ground is even and flat | |
| 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 | |
| float | ImpactFalloff = 5f |
| the speed at which external forces get lerped to zero | |
| float | MaximumFallSpeed = 20.0f |
| the maximum vertical velocity the character can have while falling | |
| 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 | |
| Vector3 | GroundNormal = Vector3.zero |
| the current surface normal vector | |
| bool | SlideOnSteepSurfaces = true |
| whether or not the character should slide while standing on steep surfaces | |
| float | SlidingSpeed = 15f |
| the speed at which the character should slide | |
| float | SlidingSpeedControl = 0.4f |
| the control the player has on the speed while sliding down | |
| float | SlidingDirectionControl = 1f |
| the control the player has on the direction while sliding down | |
| 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) | |
| bool | GravityActive = true |
| whether or not the gravity is currently being applied to this character | |
| 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 | |
| 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 | |
| Vector3 | Speed |
| the current speed of the character | |
| Vector3 | Velocity |
| the current velocity | |
| Vector3 | VelocityLastFrame |
| the velocity of the character last frame | |
| Vector3 | Acceleration |
| the current acceleration | |
| bool | Grounded |
| whether or not the character is grounded | |
| bool | JustGotGrounded |
| whether or not the character got grounded this frame | |
| Vector3 | CurrentMovement |
| the current movement of the character | |
| Vector3 | CurrentDirection |
| the direction the character is going in | |
| float | Friction |
| the current friction | |
| Vector3 | AddedForce |
| the current added force, to be added to the character's movement | |
| bool | FreeMovement = true |
| whether or not the character is in free movement mode or not | |
Protected Member Functions | |
| override void | Awake () |
| On awake we store our various components for future use. | |
| override void | LateUpdate () |
| On late update we apply any impact we have in store, and store our velocity for use next frame. | |
| override void | Update () |
| On Update we process our Update computations if UpdateMode is set to Update. | |
| override void | FixedUpdate () |
| On FixedUpdate we process our Update computations if UpdateMode is set to FixedUpdate. | |
| virtual void | ProcessUpdate () |
| Computes the new velocity and moves the character. | |
| virtual void | AddInput () |
| Determines the new velocity based on the slope we're on and the input. | |
| virtual void | AddGravity () |
| Adds the gravity to the new velocity and any AddedForce we may have. | |
| virtual void | MoveWithPlatform () |
| Moves and rotates the character controller to follow any moving platform we may be standing on. | |
| virtual void | ComputeVelocityDelta () |
| Computes the motion vector to apply to the character controller. | |
| virtual void | MoveCharacterController () |
| Moves the character controller by the computed _motion. | |
| virtual void | DetectNewMovingPlatform () |
| Detects any moving platform we may be standing on. | |
| virtual void | ComputeNewVelocity () |
| Determines the new Velocity value based on our position and our position last frame. | |
| virtual void | HandleGroundContact () |
| We handle ground contact, velocity transfer and moving platforms. | |
| override void | DetermineDirection () |
| Determines the direction based on the current movement. | |
| override void | HandleFriction () |
| Handles friction with ground surfaces, coming soon. | |
| 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. | |
| virtual void | HandleAdvancedGroundDetection () |
| virtual void | CastRayDownwards () |
| Casts a ray downwards and adjusts distances if needed. | |
| float | AdjustDistance (float distance) |
| Returns the real distance between the extremity of the character and the ground. | |
| virtual void | OnTriggerEnter (Collider other) |
| When triggering with something else, we check if it's a moving platform and we push ourselves if needed. | |
| virtual void | GetMovingPlatformVelocity () |
| Gets the current moving platform's velocity. | |
| virtual IEnumerator | SubstractNewPlatformVelocity () |
| Computes the relative velocity. | |
| virtual bool | ShouldMoveWithPlatformThisFrame () |
| Whether or not our character should move with the moving platform this frame. | |
| override void | CheckIfGrounded () |
| Grounded check. | |
| virtual void | ApplyImpact () |
| Applies the stored impact to the character. | |
| Protected Member Functions inherited from MoreMountains.TopDownEngine.TopDownController | |
| virtual void | ComputeSpeed () |
| Computes the speed. | |
Properties | |
| override Vector3 | ColliderCenter [get] |
| returns the center coordinate of the collider | |
| override Vector3 | ColliderBottom [get] |
| returns the bottom coordinate of the collider | |
| override Vector3 | ColliderTop [get] |
| returns the top coordinate of the collider | |
| virtual bool | ExitedTooSteepSlopeThisFrame [get, set] |
| whether or not the character just entered a slope/ground not too steep this frame | |
| override bool | OnAMovingPlatform [get] |
| whether or not the character is on a moving platform | |
| override Vector3 | MovingPlatformSpeed [get] |
| the speed of the moving platform | |
| Quaternion | MoveWithPlatformGlobalRotation [get] |
| Quaternion | MoveWithPlatformRotationDiff [get] |
| Properties inherited from MoreMountains.TopDownEngine.TopDownController | |
| virtual Vector3 | ColliderCenter [get] |
| the collider's center coordinates | |
| virtual Vector3 | ColliderBottom [get] |
| the collider's bottom coordinates | |
| virtual Vector3 | ColliderTop [get] |
| the collider's top coordinates | |
| virtual GameObject | ObjectBelow [get, set] |
| the object (if any) below our character | |
| virtual SurfaceModifier | SurfaceModifierBelow [get, set] |
| the surface modifier object below our character (if any) | |
| virtual Vector3 | AppliedImpact [get] |
| virtual bool | OnAMovingPlatform [get, set] |
| whether or not the character is on a moving platform | |
| virtual Vector3 | MovingPlatformSpeed [get, set] |
| the speed of the moving platform | |
| 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 |
|
get |
|
get |
the speed of the moving platform
|
get |
whether or not the character is on a moving platform