TopDown Engine v4.5
Loading...
Searching...
No Matches
MoreMountains.TopDownEngine.TopDownController2D Class Reference

a controller to move a rigidbody2D and collider2D around in top down view More...

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

Public Member Functions

override void Impact (Vector3 direction, float force)
 Another way to add a force of the specified force and direction.
override void AddForce (Vector3 movement)
 Adds a force of the specified vector.
override void SetMovement (Vector3 movement)
 Sets the current movement.
override void MovePosition (Vector3 newPosition, bool targetTransform=false)
 Tries to move to the specified position.
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 void SetMovingPlatform (MovingPlatform2D platform)
 Sets a moving platform to this controller.
override void SetKinematic (bool state)
 Sets this rigidbody as kinematic.
override void CollisionsOn ()
 Enables the collider.
override void CollisionsOff ()
 Disables the collider.
override void DetectObstacles (float distance, Vector3 offset)
 Performs a cardinal collision check and stores collision objects informations.
override void Reset ()
 On reset, we reset our rb's velocity.
Public Member Functions inherited from MoreMountains.TopDownEngine.TopDownController
virtual void SetGravityActive (bool status)
 Sets gravity active or inactive.
virtual bool CanGoBackToOriginalSize ()
 Returns true if the controller's collider can go back to original size without hitting an obstacle, false otherwise.

Public Attributes

bool OverHole = false
 whether or not the character is above a hole right now
LayerMask GroundLayerMask = LayerManager.GroundLayerMask
 the layer mask to consider as ground
LayerMask HoleLayerMask = LayerManager.HoleLayerMask
 the layer mask to consider as holes
LayerMask ObstaclesLayerMask = LayerManager.ObstaclesLayerMask
 the layer to consider as obstacles (will prevent movement)
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 grabd our components.
override void CheckIfGrounded ()
 Determines whether or not this character is grounded.
override void FixedUpdate ()
 On fixed update, we move our rigidbody.
virtual void ComputeNewVelocity ()
 Determines the new Velocity value based on our position and our position last frame.
override void Update ()
 On update we determine our acceleration.
override void LateUpdate ()
 On late update, we apply an impact.
override void HandleFriction ()
 Handles the friction, still a work in progress (todo)
virtual void ApplyImpact ()
 Applies the current impact.
override void DetermineDirection ()
 Determines the controller's current direction.
Protected Member Functions inherited from MoreMountains.TopDownEngine.TopDownController
virtual void ComputeSpeed ()
 Computes the speed.

Protected Attributes

Rigidbody2D _rigidBody
BoxCollider2D _boxCollider
bool _boxColliderNull
CapsuleCollider2D _capsuleCollider
bool _capsuleColliderNull
CircleCollider2D _circleCollider
bool _circleColliderNull
Vector2 _originalColliderSize
Vector3 _originalColliderCenter
Vector3 _originalSizeRaycastOrigin
Vector3 _orientedMovement
Collider2D _groundedTest
Collider2D _holeTestMin
Collider2D _holeTestMax
MovingPlatform2D _movingPlatform
Vector3 _movingPlatformPositionLastFrame
RaycastHit2D _raycastUp
RaycastHit2D _raycastDown
RaycastHit2D _raycastLeft
RaycastHit2D _raycastRight
Protected Attributes inherited from MoreMountains.TopDownEngine.TopDownController
Vector3 _positionLastFrame
Vector3 _speedComputation
bool _groundedLastFrame
Vector3 _impact

Properties

override Vector3 ColliderCenter [get]
 the collider's center position
override Vector3 ColliderBottom [get]
 the collider's bottom position
override Vector3 ColliderTop [get]
 the collider's top position
override bool OnAMovingPlatform [get]
 whether or not the character is on a moving platform
override Vector3 MovingPlatformSpeed [get]
 the speed of the moving platform
Vector2 ColliderSize [get, set]
Vector2 ColliderOffset [get, set]
Bounds ColliderBounds [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

Detailed Description

a controller to move a rigidbody2D and collider2D around in top down view

Member Function Documentation

◆ AddForce()

override void MoreMountains.TopDownEngine.TopDownController2D.AddForce ( Vector3 movement)
virtual

Adds a force of the specified vector.

Parameters
movement

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ ApplyImpact()

virtual void MoreMountains.TopDownEngine.TopDownController2D.ApplyImpact ( )
protectedvirtual

Applies the current impact.

◆ Awake()

override void MoreMountains.TopDownEngine.TopDownController2D.Awake ( )
protectedvirtual

On awake we grabd our components.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ CheckIfGrounded()

override void MoreMountains.TopDownEngine.TopDownController2D.CheckIfGrounded ( )
protectedvirtual

Determines whether or not this character is grounded.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ CollisionsOff()

override void MoreMountains.TopDownEngine.TopDownController2D.CollisionsOff ( )
virtual

Disables the collider.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ CollisionsOn()

override void MoreMountains.TopDownEngine.TopDownController2D.CollisionsOn ( )
virtual

Enables the collider.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ ComputeNewVelocity()

virtual void MoreMountains.TopDownEngine.TopDownController2D.ComputeNewVelocity ( )
protectedvirtual

Determines the new Velocity value based on our position and our position last frame.

◆ DetectObstacles()

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

Performs a cardinal collision check and stores collision objects informations.

Parameters
distance
offset

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ DetermineDirection()

override void MoreMountains.TopDownEngine.TopDownController2D.DetermineDirection ( )
protectedvirtual

Determines the controller's current direction.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ FixedUpdate()

override void MoreMountains.TopDownEngine.TopDownController2D.FixedUpdate ( )
protectedvirtual

On fixed update, we move our rigidbody.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ HandleFriction()

override void MoreMountains.TopDownEngine.TopDownController2D.HandleFriction ( )
protectedvirtual

Handles the friction, still a work in progress (todo)

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ Impact()

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

Another way to add a force of the specified force and direction.

Parameters
direction
force

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ LateUpdate()

override void MoreMountains.TopDownEngine.TopDownController2D.LateUpdate ( )
protectedvirtual

On late update, we apply an impact.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ MovePosition()

override void MoreMountains.TopDownEngine.TopDownController2D.MovePosition ( Vector3 newPosition,
bool targetTransform = false )
virtual

Tries to move to the specified position.

Parameters
newPosition

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ Reset()

override void MoreMountains.TopDownEngine.TopDownController2D.Reset ( )
virtual

On reset, we reset our rb's velocity.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ ResetColliderSize()

override void MoreMountains.TopDownEngine.TopDownController2D.ResetColliderSize ( )
virtual

Returns the collider to its initial size.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ ResizeColliderHeight()

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

Resizes the collider to the new size set in parameters.

Parameters
newSizeNew size.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ SetKinematic()

override void MoreMountains.TopDownEngine.TopDownController2D.SetKinematic ( bool state)
virtual

Sets this rigidbody as kinematic.

Parameters
state

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ SetMovement()

override void MoreMountains.TopDownEngine.TopDownController2D.SetMovement ( Vector3 movement)
virtual

Sets the current movement.

Parameters
movement

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

◆ SetMovingPlatform()

virtual void MoreMountains.TopDownEngine.TopDownController2D.SetMovingPlatform ( MovingPlatform2D platform)
virtual

Sets a moving platform to this controller.

Parameters
platform

◆ Update()

override void MoreMountains.TopDownEngine.TopDownController2D.Update ( )
protectedvirtual

On update we determine our acceleration.

Reimplemented from MoreMountains.TopDownEngine.TopDownController.

Member Data Documentation

◆ _boxCollider

BoxCollider2D MoreMountains.TopDownEngine.TopDownController2D._boxCollider
protected

◆ _boxColliderNull

bool MoreMountains.TopDownEngine.TopDownController2D._boxColliderNull
protected

◆ _capsuleCollider

CapsuleCollider2D MoreMountains.TopDownEngine.TopDownController2D._capsuleCollider
protected

◆ _capsuleColliderNull

bool MoreMountains.TopDownEngine.TopDownController2D._capsuleColliderNull
protected

◆ _circleCollider

CircleCollider2D MoreMountains.TopDownEngine.TopDownController2D._circleCollider
protected

◆ _circleColliderNull

bool MoreMountains.TopDownEngine.TopDownController2D._circleColliderNull
protected

◆ _groundedTest

Collider2D MoreMountains.TopDownEngine.TopDownController2D._groundedTest
protected

◆ _holeTestMax

Collider2D MoreMountains.TopDownEngine.TopDownController2D._holeTestMax
protected

◆ _holeTestMin

Collider2D MoreMountains.TopDownEngine.TopDownController2D._holeTestMin
protected

◆ _movingPlatform

MovingPlatform2D MoreMountains.TopDownEngine.TopDownController2D._movingPlatform
protected

◆ _movingPlatformPositionLastFrame

Vector3 MoreMountains.TopDownEngine.TopDownController2D._movingPlatformPositionLastFrame
protected

◆ _orientedMovement

Vector3 MoreMountains.TopDownEngine.TopDownController2D._orientedMovement
protected

◆ _originalColliderCenter

Vector3 MoreMountains.TopDownEngine.TopDownController2D._originalColliderCenter
protected

◆ _originalColliderSize

Vector2 MoreMountains.TopDownEngine.TopDownController2D._originalColliderSize
protected

◆ _originalSizeRaycastOrigin

Vector3 MoreMountains.TopDownEngine.TopDownController2D._originalSizeRaycastOrigin
protected

◆ _raycastDown

RaycastHit2D MoreMountains.TopDownEngine.TopDownController2D._raycastDown
protected

◆ _raycastLeft

RaycastHit2D MoreMountains.TopDownEngine.TopDownController2D._raycastLeft
protected

◆ _raycastRight

RaycastHit2D MoreMountains.TopDownEngine.TopDownController2D._raycastRight
protected

◆ _raycastUp

RaycastHit2D MoreMountains.TopDownEngine.TopDownController2D._raycastUp
protected

◆ _rigidBody

Rigidbody2D MoreMountains.TopDownEngine.TopDownController2D._rigidBody
protected

◆ GroundLayerMask

LayerMask MoreMountains.TopDownEngine.TopDownController2D.GroundLayerMask = LayerManager.GroundLayerMask

the layer mask to consider as ground

◆ HoleLayerMask

LayerMask MoreMountains.TopDownEngine.TopDownController2D.HoleLayerMask = LayerManager.HoleLayerMask

the layer mask to consider as holes

◆ ObstaclesLayerMask

LayerMask MoreMountains.TopDownEngine.TopDownController2D.ObstaclesLayerMask = LayerManager.ObstaclesLayerMask

the layer to consider as obstacles (will prevent movement)

◆ OverHole

bool MoreMountains.TopDownEngine.TopDownController2D.OverHole = false

whether or not the character is above a hole right now

Property Documentation

◆ ColliderBottom

override Vector3 MoreMountains.TopDownEngine.TopDownController2D.ColliderBottom
get

the collider's bottom position

◆ ColliderBounds

Bounds MoreMountains.TopDownEngine.TopDownController2D.ColliderBounds
get

◆ ColliderCenter

override Vector3 MoreMountains.TopDownEngine.TopDownController2D.ColliderCenter
get

the collider's center position

◆ ColliderOffset

Vector2 MoreMountains.TopDownEngine.TopDownController2D.ColliderOffset
getset

◆ ColliderSize

Vector2 MoreMountains.TopDownEngine.TopDownController2D.ColliderSize
getset

◆ ColliderTop

override Vector3 MoreMountains.TopDownEngine.TopDownController2D.ColliderTop
get

the collider's top position

◆ MovingPlatformSpeed

override Vector3 MoreMountains.TopDownEngine.TopDownController2D.MovingPlatformSpeed
get

the speed of the moving platform

◆ OnAMovingPlatform

override bool MoreMountains.TopDownEngine.TopDownController2D.OnAMovingPlatform
get

whether or not the character is on a moving platform


The documentation for this class was generated from the following file:
  • H:/Code/MoreMountains/topdownengine/Assets/TopDownEngine/Common/Scripts/Characters/Core/TopDownController2D.cs