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

Add this ability to a Character to have it handle ground movement (walk, and potentially run, crawl, etc) in x and z direction for 3D, x and y for 2D Animator parameters : Speed (float), Walking (bool) More...

Inheritance diagram for MoreMountains.TopDownEngine.CharacterMovement:
MoreMountains.TopDownEngine.CharacterAbility MoreMountains.TopDownEngine.TopDownMonoBehaviour MoreMountains.Tools.MMMonoBehaviour

Public Types

enum  Movements {
  Free , Strict2DirectionsHorizontal , Strict2DirectionsVertical , Strict4Directions ,
  Strict8Directions
}
 the possible rotation modes for the character More...

Public Member Functions

override void ResetAbility ()
 Resets character movement states and speeds.
override void ProcessAbility ()
 The second of the 3 passes you can have in your ability. Think of it as Update()
virtual void SetMovement (Vector2 value)
 Sets the horizontal move value.
virtual void SetHorizontalMovement (float value)
 Sets the horizontal part of the movement.
virtual void SetVerticalMovement (float value)
 Sets the vertical part of the movement.
virtual void ApplyMovementMultiplier (float movementMultiplier, float duration)
 Applies a movement multiplier for the specified duration.
virtual void SetContextSpeedMultiplier (float newMovementSpeedMultiplier)
 Stacks a new context speed multiplier.
virtual void ResetContextSpeedMultiplier ()
 Revers the context speed multiplier to its previous value.
virtual void ResetSpeed ()
 Resets this character's speed.
override void UpdateAnimator ()
 Sends the current speed and the current value of the Walking state to the animator.
Public Member Functions inherited from MoreMountains.TopDownEngine.CharacterAbility
delegate void AbilityEvent ()
virtual string HelpBoxText ()
 This method is only used to display a helpbox text at the beginning of the ability's inspector.
virtual void ForceInitialization ()
 Call this any time you want to force this ability to initialize (again)
virtual void ResetInput ()
 Resets all input for this ability. Can be overridden for ability specific directives.
virtual void EarlyProcessAbility ()
 The first of the 3 passes you can have in your ability. Think of it as EarlyUpdate() if it existed.
virtual void LateProcessAbility ()
 The last of the 3 passes you can have in your ability. Think of it as LateUpdate()
virtual void PermitAbility (bool abilityPermitted)
 Changes the status of the ability's permission.
virtual void Flip ()
 Override this to specify what should happen in this ability when the character flips.
virtual void SetInputManager (InputManager newInputManager)
 Changes the reference to the input manager with the one set in parameters.
virtual void PlayAbilityStartSfx ()
 Plays the ability start sound effect.
virtual void PlayAbilityUsedSfx ()
 Plays the ability used sound effect.
virtual void StopAbilityUsedSfx ()
 Stops the ability used sound effect.
virtual void PlayAbilityStopSfx ()
 Plays the ability stop sound effect.
virtual void PlayAbilityStartFeedbacks ()
 Plays the ability start sound effect.
virtual void StopStartFeedbacks ()
 Stops the ability used sound effect.
virtual void PlayAbilityStopFeedbacks ()
 Plays the ability stop sound effect.

Public Attributes

Movements Movement = Movements.Free
 whether the character can move freely, in 2D only, in 4 or 8 cardinal directions
bool InputAuthorized = true
 whether or not movement input is authorized at that time
bool AnalogInput = false
 whether or not input should be analog
bool ScriptDrivenInput = false
 whether or not input should be set from another script
float WalkSpeed = 6f
 the speed of the character when it's walking
bool ShouldSetMovement = true
 whether or not this component should set the controller's movement
float IdleThreshold = 0.05f
 the speed threshold after which the character is not considered idle anymore
float Acceleration = 10f
 the acceleration to apply to the current speed / 0f : no acceleration, instant full speed
float Deceleration = 10f
 the deceleration to apply to the current speed / 0f : no deceleration, instant stop
bool InterpolateMovementSpeed = false
 whether or not to interpolate movement speed
Stack< float > ContextSpeedStack = new Stack<float>()
 the multiplier to apply to the horizontal movement, applied by contextual elements (movement zones, etc)
ParticleSystem[] WalkParticles
 the particles to trigger while walking
ParticleSystem[] TouchTheGroundParticles
 the particles to trigger when touching the ground
AudioClip[] TouchTheGroundSfx
 the sfx to trigger when touching the ground
Public Attributes inherited from MoreMountains.TopDownEngine.CharacterAbility
AudioClip AbilityStartSfx
 the sound fx to play when the ability starts
AudioClip AbilityInProgressSfx
 the sound fx to play while the ability is running
AudioClip AbilityStopSfx
 the sound fx to play when the ability stops
MMFeedbacks AbilityStartFeedbacks
 the feedbacks to play when the ability starts
MMFeedbacks AbilityStopFeedbacks
 the feedbacks to play when the ability stops
bool AbilityPermitted = true
 if true, this ability can perform as usual, if not, it'll be ignored. You can use this to unlock abilities over time for example
CharacterStates.MovementStates[] BlockingMovementStates
 an array containing all the blocking movement states. If the Character is in one of these states and tries to trigger this ability, it won't be permitted. Useful to prevent this ability from being used while Idle or Swimming, for example.
CharacterStates.CharacterConditions[] BlockingConditionStates
 an array containing all the blocking condition states. If the Character is in one of these states and tries to trigger this ability, it won't be permitted. Useful to prevent this ability from being used while dead, for example.
Weapon.WeaponStates[] BlockingWeaponStates
 an array containing all the blocking weapon states. If one of the character's weapons is in one of these states and yet the character tries to trigger this ability, it won't be permitted. Useful to prevent this ability from being used while attacking, for example.
AbilityEvent OnAbilityStart
AbilityEvent OnAbilityStop

Protected Member Functions

override void Initialization ()
 On Initialization, we set our movement speed to WalkSpeed.
override void HandleInput ()
 Called at the very start of the ability's cycle, and intended to be overridden, looks for input and calls methods if conditions are met.
virtual IEnumerator ApplyMovementMultiplierCo (float movementMultiplier, float duration)
 A coroutine used to apply a movement multiplier for a certain duration only.
virtual void HandleDirection ()
 Modifies player input to account for the selected movement mode.
virtual void HandleMovement ()
 Called at Update(), handles horizontal movement.
virtual void HandleFrozen ()
 Describes what happens when the character is in the frozen state.
virtual void SetMovement ()
 Moves the controller.
virtual void CheckJustGotGrounded ()
 Every frame, checks if we just hit the ground, and if yes, changes the state and triggers a particle effect.
virtual void Feedbacks ()
 Plays particles when walking, and particles and sounds when landing.
override void OnRespawn ()
 On Respawn, resets the speed.
override void OnDeath ()
 Override this to describe what should happen to this ability when the character respawns.
virtual void DisableWalkParticles ()
 Disables all walk particle systems that may be playing.
override void OnDisable ()
 On disable we make sure to turn off anything that could still be playing.
override void InitializeAnimatorParameters ()
 Adds required animator parameters to the animator parameters list if they exist.
Protected Member Functions inherited from MoreMountains.TopDownEngine.CharacterAbility
virtual void Awake ()
 On awake we proceed to pre initializing our ability.
virtual void Start ()
 On Start(), we call the ability's intialization.
virtual void PreInitialization ()
 A method you can override to have an initialization before the actual initialization.
virtual void BindAnimator ()
 Binds the animator from the character and initializes the animator parameters.
virtual void InternalHandleInput ()
 Internal method to check if an input manager is present or not.
virtual void RegisterAnimatorParameter (string parameterName, AnimatorControllerParameterType parameterType, out int parameter)
 Registers a new animator parameter to the list.
virtual void OnHit ()
 Override this to describe what should happen to this ability when the character takes a hit.
virtual void OnEnable ()
 On enable, we bind our respawn delegate.

Protected Attributes

float _movementSpeed
float _horizontalMovement
float _verticalMovement
Vector3 _movementVector
Vector2 _currentInput = Vector2.zero
Vector2 _normalizedInput
Vector2 _lerpedInput = Vector2.zero
float _acceleration = 0f
bool _walkParticlesPlaying = false
int _speedAnimationParameter
int _walkingAnimationParameter
int _idleAnimationParameter
Protected Attributes inherited from MoreMountains.TopDownEngine.CharacterAbility
Character _character
TopDownController _controller
TopDownController2D _controller2D
TopDownController3D _controller3D
GameObject _model
Health _health
CharacterMovement _characterMovement
InputManager _inputManager
Animator _animator = null
CharacterStates _state
SpriteRenderer _spriteRenderer
MMStateMachine< CharacterStates.MovementStates_movement
MMStateMachine< CharacterStates.CharacterConditions_condition
AudioSource _abilityInProgressSfx
bool _abilityInitialized = false
float _verticalInput
float _horizontalInput
bool _startFeedbackIsPlaying = false
List< CharacterHandleWeapon_handleWeaponList

Static Protected Attributes

const string _speedAnimationParameterName = "Speed"
const string _walkingAnimationParameterName = "Walking"
const string _idleAnimationParameterName = "Idle"

Properties

virtual float MovementSpeed [get, set]
 the current reference movement speed
virtual bool MovementForbidden [get, set]
 if this is true, movement will be forbidden (as well as flip)
virtual float MovementSpeedMaxMultiplier = float.MaxValue [get, set]
float MovementSpeedMultiplier [get, set]
 the multiplier to apply to the horizontal movement
virtual float ContextSpeedMultiplier [get]
Properties inherited from MoreMountains.TopDownEngine.CharacterAbility
virtual bool AbilityAuthorized [get]
virtual bool AbilityInitialized [get]
 whether or not this ability has been initialized

Detailed Description

Add this ability to a Character to have it handle ground movement (walk, and potentially run, crawl, etc) in x and z direction for 3D, x and y for 2D Animator parameters : Speed (float), Walking (bool)

Member Enumeration Documentation

◆ Movements

the possible rotation modes for the character

Enumerator
Free 
Strict2DirectionsHorizontal 
Strict2DirectionsVertical 
Strict4Directions 
Strict8Directions 

Member Function Documentation

◆ ApplyMovementMultiplier()

virtual void MoreMountains.TopDownEngine.CharacterMovement.ApplyMovementMultiplier ( float movementMultiplier,
float duration )
virtual

Applies a movement multiplier for the specified duration.

Parameters
movementMultiplier
duration

◆ ApplyMovementMultiplierCo()

virtual IEnumerator MoreMountains.TopDownEngine.CharacterMovement.ApplyMovementMultiplierCo ( float movementMultiplier,
float duration )
protectedvirtual

A coroutine used to apply a movement multiplier for a certain duration only.

Parameters
movementMultiplier
duration
Returns

◆ CheckJustGotGrounded()

virtual void MoreMountains.TopDownEngine.CharacterMovement.CheckJustGotGrounded ( )
protectedvirtual

Every frame, checks if we just hit the ground, and if yes, changes the state and triggers a particle effect.

◆ DisableWalkParticles()

virtual void MoreMountains.TopDownEngine.CharacterMovement.DisableWalkParticles ( )
protectedvirtual

Disables all walk particle systems that may be playing.

◆ Feedbacks()

virtual void MoreMountains.TopDownEngine.CharacterMovement.Feedbacks ( )
protectedvirtual

Plays particles when walking, and particles and sounds when landing.

◆ HandleDirection()

virtual void MoreMountains.TopDownEngine.CharacterMovement.HandleDirection ( )
protectedvirtual

Modifies player input to account for the selected movement mode.

◆ HandleFrozen()

virtual void MoreMountains.TopDownEngine.CharacterMovement.HandleFrozen ( )
protectedvirtual

Describes what happens when the character is in the frozen state.

◆ HandleInput()

override void MoreMountains.TopDownEngine.CharacterMovement.HandleInput ( )
protectedvirtual

Called at the very start of the ability's cycle, and intended to be overridden, looks for input and calls methods if conditions are met.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ HandleMovement()

virtual void MoreMountains.TopDownEngine.CharacterMovement.HandleMovement ( )
protectedvirtual

Called at Update(), handles horizontal movement.

◆ Initialization()

override void MoreMountains.TopDownEngine.CharacterMovement.Initialization ( )
protectedvirtual

On Initialization, we set our movement speed to WalkSpeed.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ InitializeAnimatorParameters()

override void MoreMountains.TopDownEngine.CharacterMovement.InitializeAnimatorParameters ( )
protectedvirtual

Adds required animator parameters to the animator parameters list if they exist.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ OnDeath()

override void MoreMountains.TopDownEngine.CharacterMovement.OnDeath ( )
protectedvirtual

Override this to describe what should happen to this ability when the character respawns.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ OnDisable()

override void MoreMountains.TopDownEngine.CharacterMovement.OnDisable ( )
protectedvirtual

On disable we make sure to turn off anything that could still be playing.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ OnRespawn()

override void MoreMountains.TopDownEngine.CharacterMovement.OnRespawn ( )
protectedvirtual

On Respawn, resets the speed.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ ProcessAbility()

override void MoreMountains.TopDownEngine.CharacterMovement.ProcessAbility ( )
virtual

The second of the 3 passes you can have in your ability. Think of it as Update()

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ ResetAbility()

override void MoreMountains.TopDownEngine.CharacterMovement.ResetAbility ( )
virtual

Resets character movement states and speeds.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ ResetContextSpeedMultiplier()

virtual void MoreMountains.TopDownEngine.CharacterMovement.ResetContextSpeedMultiplier ( )
virtual

Revers the context speed multiplier to its previous value.

◆ ResetSpeed()

virtual void MoreMountains.TopDownEngine.CharacterMovement.ResetSpeed ( )
virtual

Resets this character's speed.

◆ SetContextSpeedMultiplier()

virtual void MoreMountains.TopDownEngine.CharacterMovement.SetContextSpeedMultiplier ( float newMovementSpeedMultiplier)
virtual

Stacks a new context speed multiplier.

Parameters
newMovementSpeedMultiplier

◆ SetHorizontalMovement()

virtual void MoreMountains.TopDownEngine.CharacterMovement.SetHorizontalMovement ( float value)
virtual

Sets the horizontal part of the movement.

Parameters
value

◆ SetMovement() [1/2]

virtual void MoreMountains.TopDownEngine.CharacterMovement.SetMovement ( )
protectedvirtual

Moves the controller.

◆ SetMovement() [2/2]

virtual void MoreMountains.TopDownEngine.CharacterMovement.SetMovement ( Vector2 value)
virtual

Sets the horizontal move value.

Parameters
valueHorizontal move value, between -1 and 1 - positive : will move to the right, negative : will move left

◆ SetVerticalMovement()

virtual void MoreMountains.TopDownEngine.CharacterMovement.SetVerticalMovement ( float value)
virtual

Sets the vertical part of the movement.

Parameters
value

◆ UpdateAnimator()

override void MoreMountains.TopDownEngine.CharacterMovement.UpdateAnimator ( )
virtual

Sends the current speed and the current value of the Walking state to the animator.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

Member Data Documentation

◆ _acceleration

float MoreMountains.TopDownEngine.CharacterMovement._acceleration = 0f
protected

◆ _currentInput

Vector2 MoreMountains.TopDownEngine.CharacterMovement._currentInput = Vector2.zero
protected

◆ _horizontalMovement

float MoreMountains.TopDownEngine.CharacterMovement._horizontalMovement
protected

◆ _idleAnimationParameter

int MoreMountains.TopDownEngine.CharacterMovement._idleAnimationParameter
protected

◆ _idleAnimationParameterName

const string MoreMountains.TopDownEngine.CharacterMovement._idleAnimationParameterName = "Idle"
staticprotected

◆ _lerpedInput

Vector2 MoreMountains.TopDownEngine.CharacterMovement._lerpedInput = Vector2.zero
protected

◆ _movementSpeed

float MoreMountains.TopDownEngine.CharacterMovement._movementSpeed
protected

◆ _movementVector

Vector3 MoreMountains.TopDownEngine.CharacterMovement._movementVector
protected

◆ _normalizedInput

Vector2 MoreMountains.TopDownEngine.CharacterMovement._normalizedInput
protected

◆ _speedAnimationParameter

int MoreMountains.TopDownEngine.CharacterMovement._speedAnimationParameter
protected

◆ _speedAnimationParameterName

const string MoreMountains.TopDownEngine.CharacterMovement._speedAnimationParameterName = "Speed"
staticprotected

◆ _verticalMovement

float MoreMountains.TopDownEngine.CharacterMovement._verticalMovement
protected

◆ _walkingAnimationParameter

int MoreMountains.TopDownEngine.CharacterMovement._walkingAnimationParameter
protected

◆ _walkingAnimationParameterName

const string MoreMountains.TopDownEngine.CharacterMovement._walkingAnimationParameterName = "Walking"
staticprotected

◆ _walkParticlesPlaying

bool MoreMountains.TopDownEngine.CharacterMovement._walkParticlesPlaying = false
protected

◆ Acceleration

float MoreMountains.TopDownEngine.CharacterMovement.Acceleration = 10f

the acceleration to apply to the current speed / 0f : no acceleration, instant full speed

◆ AnalogInput

bool MoreMountains.TopDownEngine.CharacterMovement.AnalogInput = false

whether or not input should be analog

◆ ContextSpeedStack

Stack<float> MoreMountains.TopDownEngine.CharacterMovement.ContextSpeedStack = new Stack<float>()

the multiplier to apply to the horizontal movement, applied by contextual elements (movement zones, etc)

◆ Deceleration

float MoreMountains.TopDownEngine.CharacterMovement.Deceleration = 10f

the deceleration to apply to the current speed / 0f : no deceleration, instant stop

◆ IdleThreshold

float MoreMountains.TopDownEngine.CharacterMovement.IdleThreshold = 0.05f

the speed threshold after which the character is not considered idle anymore

◆ InputAuthorized

bool MoreMountains.TopDownEngine.CharacterMovement.InputAuthorized = true

whether or not movement input is authorized at that time

◆ InterpolateMovementSpeed

bool MoreMountains.TopDownEngine.CharacterMovement.InterpolateMovementSpeed = false

whether or not to interpolate movement speed

◆ Movement

Movements MoreMountains.TopDownEngine.CharacterMovement.Movement = Movements.Free

whether the character can move freely, in 2D only, in 4 or 8 cardinal directions

◆ ScriptDrivenInput

bool MoreMountains.TopDownEngine.CharacterMovement.ScriptDrivenInput = false

whether or not input should be set from another script

◆ ShouldSetMovement

bool MoreMountains.TopDownEngine.CharacterMovement.ShouldSetMovement = true

whether or not this component should set the controller's movement

◆ TouchTheGroundParticles

ParticleSystem [] MoreMountains.TopDownEngine.CharacterMovement.TouchTheGroundParticles

the particles to trigger when touching the ground

◆ TouchTheGroundSfx

AudioClip [] MoreMountains.TopDownEngine.CharacterMovement.TouchTheGroundSfx

the sfx to trigger when touching the ground

◆ WalkParticles

ParticleSystem [] MoreMountains.TopDownEngine.CharacterMovement.WalkParticles

the particles to trigger while walking

◆ WalkSpeed

float MoreMountains.TopDownEngine.CharacterMovement.WalkSpeed = 6f

the speed of the character when it's walking

Property Documentation

◆ ContextSpeedMultiplier

virtual float MoreMountains.TopDownEngine.CharacterMovement.ContextSpeedMultiplier
get

◆ MovementForbidden

virtual bool MoreMountains.TopDownEngine.CharacterMovement.MovementForbidden
getset

if this is true, movement will be forbidden (as well as flip)

◆ MovementSpeed

virtual float MoreMountains.TopDownEngine.CharacterMovement.MovementSpeed
getset

the current reference movement speed

◆ MovementSpeedMaxMultiplier

virtual float MoreMountains.TopDownEngine.CharacterMovement.MovementSpeedMaxMultiplier = float.MaxValue
getset

◆ MovementSpeedMultiplier

float MoreMountains.TopDownEngine.CharacterMovement.MovementSpeedMultiplier
getset

the multiplier to apply to the horizontal movement


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