TopDown Engine  v3.6
MoreMountains.TopDownEngine.TopDownController Class Reference

Do not use this class directly, use TopDownController2D for 2D characters, or TopDownController3D for 3D characters Both of these classes inherit from this one More...

Inheritance diagram for MoreMountains.TopDownEngine.TopDownController:
MoreMountains.TopDownEngine.TopDownMonoBehaviour MoreMountains.Tools.MMMonoBehaviour MoreMountains.TopDownEngine.TopDownController2D MoreMountains.TopDownEngine.TopDownController3D

Public Member Functions

virtual void DetectObstacles (float distance, Vector3 offset)
 Performs obstacle detection "manually" More...
 
virtual void Impact (Vector3 direction, float force)
 Use this to apply an impact to a controller, moving it in the specified direction at the specified force More...
 
virtual void SetGravityActive (bool status)
 Sets gravity active or inactive More...
 
virtual void AddForce (Vector3 movement)
 Adds the specified force to the controller More...
 
virtual void SetMovement (Vector3 movement)
 Sets the current movement of the controller to the specified Vector3 More...
 
virtual void MovePosition (Vector3 newPosition)
 Moves the controller to the specified position (in world space) More...
 
virtual void ResizeColliderHeight (float newHeight, bool translateCenter=false)
 Resizes the controller's collider More...
 
virtual void ResetColliderSize ()
 Resets the controller's collider size More...
 
virtual bool CanGoBackToOriginalSize ()
 Returns true if the controller's collider can go back to original size without hitting an obstacle, false otherwise More...
 
virtual void CollisionsOn ()
 Turns the controller's collisions on More...
 
virtual void CollisionsOff ()
 Turns the controller's collisions off More...
 
virtual void SetKinematic (bool state)
 Sets the controller's rigidbody to Kinematic (or not kinematic) More...
 
virtual void Reset ()
 Resets all values for this controller More...
 

Public Attributes

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

virtual void Awake ()
 On awake, we initialize our current direction More...
 
virtual void Update ()
 On update, we check if we're grounded, and determine the direction More...
 
virtual void ComputeSpeed ()
 Computes the speed More...
 
virtual void DetermineDirection ()
 Determines the controller's current direction More...
 
virtual void FixedUpdate ()
 Called at FixedUpdate More...
 
virtual void LateUpdate ()
 On LateUpdate, computes the speed of the agent More...
 
virtual void CheckIfGrounded ()
 Checks if the character is grounded More...
 
virtual void HandleFriction ()
 Handles friction collisions More...
 

Protected Attributes

Vector3 _positionLastFrame
 
Vector3 _speedComputation
 
bool _groundedLastFrame
 
Vector3 _impact
 

Static Protected Attributes

const float _smallValue =0.0001f
 

Properties

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]
 

Detailed Description

Do not use this class directly, use TopDownController2D for 2D characters, or TopDownController3D for 3D characters Both of these classes inherit from this one

Member Function Documentation

◆ AddForce()

virtual void MoreMountains.TopDownEngine.TopDownController.AddForce ( Vector3  movement)
virtual

Adds the specified force to the controller

Parameters
movement

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ Awake()

virtual void MoreMountains.TopDownEngine.TopDownController.Awake ( )
protectedvirtual

On awake, we initialize our current direction

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ CanGoBackToOriginalSize()

virtual bool MoreMountains.TopDownEngine.TopDownController.CanGoBackToOriginalSize ( )
virtual

Returns true if the controller's collider can go back to original size without hitting an obstacle, false otherwise

Returns

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D.

◆ CheckIfGrounded()

virtual void MoreMountains.TopDownEngine.TopDownController.CheckIfGrounded ( )
protectedvirtual

◆ CollisionsOff()

virtual void MoreMountains.TopDownEngine.TopDownController.CollisionsOff ( )
virtual

Turns the controller's collisions off

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ CollisionsOn()

virtual void MoreMountains.TopDownEngine.TopDownController.CollisionsOn ( )
virtual

Turns the controller's collisions on

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ ComputeSpeed()

virtual void MoreMountains.TopDownEngine.TopDownController.ComputeSpeed ( )
protectedvirtual

Computes the speed

◆ DetectObstacles()

virtual void MoreMountains.TopDownEngine.TopDownController.DetectObstacles ( float  distance,
Vector3  offset 
)
virtual

Performs obstacle detection "manually"

Parameters
distance
offset

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ DetermineDirection()

virtual void MoreMountains.TopDownEngine.TopDownController.DetermineDirection ( )
protectedvirtual

Determines the controller's current direction

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ FixedUpdate()

virtual void MoreMountains.TopDownEngine.TopDownController.FixedUpdate ( )
protectedvirtual

◆ HandleFriction()

virtual void MoreMountains.TopDownEngine.TopDownController.HandleFriction ( )
protectedvirtual

◆ Impact()

virtual void MoreMountains.TopDownEngine.TopDownController.Impact ( Vector3  direction,
float  force 
)
virtual

Use this to apply an impact to a controller, moving it in the specified direction at the specified force

Parameters
direction
force

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ LateUpdate()

virtual void MoreMountains.TopDownEngine.TopDownController.LateUpdate ( )
protectedvirtual

On LateUpdate, computes the speed of the agent

Reimplemented in MoreMountains.TopDownEngine.TopDownController2D, and MoreMountains.TopDownEngine.TopDownController3D.

◆ MovePosition()

virtual void MoreMountains.TopDownEngine.TopDownController.MovePosition ( Vector3  newPosition)
virtual

Moves the controller to the specified position (in world space)

Parameters
newPosition

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ Reset()

virtual void MoreMountains.TopDownEngine.TopDownController.Reset ( )
virtual

Resets all values for this controller

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ ResetColliderSize()

virtual void MoreMountains.TopDownEngine.TopDownController.ResetColliderSize ( )
virtual

Resets the controller's collider size

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ ResizeColliderHeight()

virtual void MoreMountains.TopDownEngine.TopDownController.ResizeColliderHeight ( float  newHeight,
bool  translateCenter = false 
)
virtual

Resizes the controller's collider

Parameters
newHeight

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ SetGravityActive()

virtual void MoreMountains.TopDownEngine.TopDownController.SetGravityActive ( bool  status)
virtual

Sets gravity active or inactive

Parameters
status

◆ SetKinematic()

virtual void MoreMountains.TopDownEngine.TopDownController.SetKinematic ( bool  state)
virtual

Sets the controller's rigidbody to Kinematic (or not kinematic)

Parameters
state

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ SetMovement()

virtual void MoreMountains.TopDownEngine.TopDownController.SetMovement ( Vector3  movement)
virtual

Sets the current movement of the controller to the specified Vector3

Parameters
movement

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

◆ Update()

virtual void MoreMountains.TopDownEngine.TopDownController.Update ( )
protectedvirtual

On update, we check if we're grounded, and determine the direction

Reimplemented in MoreMountains.TopDownEngine.TopDownController3D, and MoreMountains.TopDownEngine.TopDownController2D.

Member Data Documentation

◆ _groundedLastFrame

bool MoreMountains.TopDownEngine.TopDownController._groundedLastFrame
protected

◆ _impact

Vector3 MoreMountains.TopDownEngine.TopDownController._impact
protected

◆ _positionLastFrame

Vector3 MoreMountains.TopDownEngine.TopDownController._positionLastFrame
protected

◆ _smallValue

const float MoreMountains.TopDownEngine.TopDownController._smallValue =0.0001f
staticprotected

◆ _speedComputation

Vector3 MoreMountains.TopDownEngine.TopDownController._speedComputation
protected

◆ Acceleration

Vector3 MoreMountains.TopDownEngine.TopDownController.Acceleration

the current acceleration

◆ AddedForce

Vector3 MoreMountains.TopDownEngine.TopDownController.AddedForce

the current added force, to be added to the character's movement

◆ CrouchedRaycastLengthMultiplier

float MoreMountains.TopDownEngine.TopDownController.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

◆ CurrentDirection

Vector3 MoreMountains.TopDownEngine.TopDownController.CurrentDirection

the direction the character is going in

◆ CurrentMovement

Vector3 MoreMountains.TopDownEngine.TopDownController.CurrentMovement

the current movement of the character

◆ FreeMovement

bool MoreMountains.TopDownEngine.TopDownController.FreeMovement = true

whether or not the character is in free movement mode or not

◆ Friction

float MoreMountains.TopDownEngine.TopDownController.Friction

the current friction

◆ Gravity

float MoreMountains.TopDownEngine.TopDownController.Gravity = 40f

the current gravity to apply to our character (positive goes down, negative goes up, higher value, higher acceleration)

◆ GravityActive

bool MoreMountains.TopDownEngine.TopDownController.GravityActive = true

whether or not the gravity is currently being applied to this character

◆ Grounded

bool MoreMountains.TopDownEngine.TopDownController.Grounded

whether or not the character is grounded

◆ JustGotGrounded

bool MoreMountains.TopDownEngine.TopDownController.JustGotGrounded

whether or not the character got grounded this frame

◆ PerformCardinalObstacleRaycastDetection

bool MoreMountains.TopDownEngine.TopDownController.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

◆ Speed

Vector3 MoreMountains.TopDownEngine.TopDownController.Speed

the current speed of the character

◆ Velocity

Vector3 MoreMountains.TopDownEngine.TopDownController.Velocity

the current velocity

◆ VelocityLastFrame

Vector3 MoreMountains.TopDownEngine.TopDownController.VelocityLastFrame

the velocity of the character last frame

Property Documentation

◆ AppliedImpact

virtual Vector3 MoreMountains.TopDownEngine.TopDownController.AppliedImpact
get

◆ ColliderBottom

virtual Vector3 MoreMountains.TopDownEngine.TopDownController.ColliderBottom
get

the collider's bottom coordinates

◆ ColliderCenter

virtual Vector3 MoreMountains.TopDownEngine.TopDownController.ColliderCenter
get

the collider's center coordinates

◆ ColliderTop

virtual Vector3 MoreMountains.TopDownEngine.TopDownController.ColliderTop
get

the collider's top coordinates

◆ CollidingWithCardinalObstacle

virtual bool MoreMountains.TopDownEngine.TopDownController.CollidingWithCardinalObstacle
getset

◆ DetectedObstacleDown

virtual GameObject MoreMountains.TopDownEngine.TopDownController.DetectedObstacleDown
getset

◆ DetectedObstacleLeft

virtual GameObject MoreMountains.TopDownEngine.TopDownController.DetectedObstacleLeft
getset

◆ DetectedObstacleRight

virtual GameObject MoreMountains.TopDownEngine.TopDownController.DetectedObstacleRight
getset

◆ DetectedObstacleUp

virtual GameObject MoreMountains.TopDownEngine.TopDownController.DetectedObstacleUp
getset

◆ MovingPlatformSpeed

virtual Vector3 MoreMountains.TopDownEngine.TopDownController.MovingPlatformSpeed
getset

the speed of the moving platform

◆ ObjectBelow

virtual GameObject MoreMountains.TopDownEngine.TopDownController.ObjectBelow
getset

the object (if any) below our character

◆ OnAMovingPlatform

virtual bool MoreMountains.TopDownEngine.TopDownController.OnAMovingPlatform
getset

whether or not the character is on a moving platform

◆ SurfaceModifierBelow

virtual SurfaceModifier MoreMountains.TopDownEngine.TopDownController.SurfaceModifierBelow
getset

the surface modifier object below our character (if any)


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