Corgi Engine  v8.8
MoreMountains.CorgiEngine.CharacterHorizontalMovement Class Reference

Add this ability to a Character to have it handle horizontal movement (walk, and potentially run, crawl, etc) Animator parameters : Speed (float), Walking (bool) More...

Inheritance diagram for MoreMountains.CorgiEngine.CharacterHorizontalMovement:
MoreMountains.CorgiEngine.CharacterAbility MoreMountains.CorgiEngine.CorgiMonoBehaviour

Public Member Functions

override string HelpBoxText ()
 This method is only used to display a helpbox text at the beginning of the ability's inspector. More...
 
override void ProcessAbility ()
 The second of the 3 passes you can have in your ability. Think of it as Update() More...
 
virtual void SetAirControlDirection (float newInputValue)
 When using low (or null) air control, this method lets you externally set the direction air control should consider as the base value More...
 
virtual void SetHorizontalMove (float value)
 Sets the horizontal move value. More...
 
virtual void ResetHorizontalSpeed ()
 A public method to reset the horizontal speed More...
 
virtual void ResetMovementSpeedMultiplier ()
 Resets the current movement multiplier to its initial value More...
 
virtual void ApplyContextSpeedMultiplier (float movementMultiplier, float duration)
 Applies a movement multiplier for the specified duration More...
 
virtual void SetContextSpeedMultiplier (float newMovementSpeedMultiplier)
 Stacks a new context speed multiplier More...
 
virtual void ResetContextSpeedMultiplier ()
 Revers the context speed multiplier to its previous value More...
 
override void UpdateAnimator ()
 Sends the current speed and the current value of the Walking state to the animator More...
 
- Public Member Functions inherited from MoreMountains.CorgiEngine.CharacterAbility
virtual void SetInputManager (InputManager inputManager)
 Sets a new input manager for this ability to get input from More...
 
virtual void BindAnimator ()
 Binds the animator from the character and initializes the animator parameters More...
 
virtual void ResetInput ()
 Resets all input for this ability. Can be overridden for ability specific directives More...
 
virtual void EarlyProcessAbility ()
 The first of the 3 passes you can have in your ability. Think of it as EarlyUpdate() if it existed More...
 
virtual void LateProcessAbility ()
 The last of the 3 passes you can have in your ability. Think of it as LateUpdate() More...
 
virtual void PermitAbility (bool abilityPermitted)
 Changes the status of the ability's permission More...
 
virtual void Flip ()
 Override this to specify what should happen in this ability when the character flips More...
 
virtual void ResetAbility ()
 Override this to reset this ability's parameters. It'll be automatically called when the character gets killed, in anticipation for its respawn. More...
 
virtual void PlayAbilityStartFeedbacks ()
 Plays the ability start sound effect More...
 
virtual void StopStartFeedbacks ()
 Stops the ability used sound effect More...
 
virtual void PlayAbilityStopFeedbacks ()
 Plays the ability stop sound effect More...
 
virtual void RegisterAnimatorParameter (string parameterName, AnimatorControllerParameterType parameterType, out int parameter)
 Registers a new animator parameter to the list More...
 

Public Attributes

float WalkSpeed = 6f
 the speed of the character when it's walking More...
 
bool ResetHorizontalSpeedBtn
 press this debug button if you decide to change the WalkSpeed at runtime, to reset its cache and have it impact your character in real time More...
 
float MovementSpeedMultiplier = 1f
 the multiplier to apply to the horizontal movement More...
 
float AbilityMovementSpeedMultiplier = 1f
 the multiplier to apply to the horizontal movement, dedicated to abilities More...
 
float PushSpeedMultiplier = 1f
 the multiplier to apply when pushing More...
 
float StateSpeedMultiplier = 1f
 the multiplier that gets set and applied by CharacterSpeed More...
 
bool FlipCharacterToFaceDirection = true
 if this is true, the character will automatically flip to face its movement direction More...
 
bool ReadInput = true
 if this is true, will get input from an input source, otherwise you'll have to set it via SetHorizontalMove() More...
 
bool InstantAcceleration = false
 if this is true, no acceleration will be applied to the movement, which will instantly be full speed (think Megaman movement). Attention : a character with instant acceleration won't be able to get knockbacked on the x axis as a regular character would, it's a tradeoff More...
 
float InputThreshold = 0.1f
 the threshold after which input is considered (usually 0.1f to eliminate small joystick noise) More...
 
float AirControl = 1f
 how much air control the player has More...
 
bool AllowFlipInTheAir = true
 whether or not the player can flip in the air More...
 
bool ActiveAfterDeath = false
 whether or not this ability should keep taking care of horizontal movement after death More...
 
MMFeedbacks TouchTheGroundFeedback
 the MMFeedbacks to play when the character hits the ground More...
 
float MinimumAirTimeBeforeFeedback = 0.2f
 the duration (in seconds) during which the character has to be airborne before a feedback can be played when touching the ground More...
 
bool StopWalkingWhenCollidingWithAWall = false
 Whether or not the state should be reset to Idle when colliding laterally with a wall. More...
 
Stack< float > ContextSpeedStack = new Stack<float>()
 
float ContextSpeedMultiplier => ContextSpeedStack.Count > 0 ? ContextSpeedStack.Peek() : 1
 
- Public Attributes inherited from MoreMountains.CorgiEngine.CharacterAbility
MMFeedbacks AbilityStartFeedbacks
 the feedbacks to play when the ability starts More...
 
MMFeedbacks AbilityStopFeedbacks
 the feedbacks to play when the ability stops More...
 
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 More...
 
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. More...
 
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. More...
 
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. More...
 

Protected Member Functions

override void Initialization ()
 On Initialization, we set our movement speed to WalkSpeed. More...
 
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 More...
 
virtual void HandleHorizontalMovement ()
 Called at Update(), handles horizontal movement More...
 
virtual bool DetectWalls (bool changeState)
 This method will return true if a wall is detected in front of the character, false otherwise More...
 
virtual void CheckJustGotGrounded ()
 Every frame, checks if we just hit the ground, and if yes, changes the state and triggers a particle effect More...
 
virtual void StoreLastTimeGrounded ()
 Computes and stores the last time we were grounded More...
 
virtual float HandleFriction (float force)
 Handles surface friction. More...
 
virtual IEnumerator ApplyContextSpeedMultiplierCo (float movementMultiplier, float duration)
 A coroutine used to apply a movement multiplier for a certain duration only More...
 
override void InitializeAnimatorParameters ()
 Adds required animator parameters to the animator parameters list if they exist More...
 
virtual void OnRevive ()
 When the character gets revived we reinit it again More...
 
override void OnEnable ()
 When the player respawns, we reinstate this agent. More...
 
override void OnDisable ()
 On disable, we stop listening for OnRevive events More...
 
- Protected Member Functions inherited from MoreMountains.CorgiEngine.CharacterAbility
virtual void Start ()
 On Start(), we call the ability's intialization More...
 
virtual void InternalHandleInput ()
 Internal method to check if an input manager is present or not More...
 
virtual void OnRespawn ()
 Override this to describe what should happen to this ability when the character respawns More...
 
virtual void OnDeath ()
 Override this to describe what should happen to this ability when the character respawns More...
 
virtual void OnHit ()
 Override this to describe what should happen to this ability when the character takes a hit More...
 

Protected Attributes

float _horizontalMovement
 
float _lastGroundedHorizontalMovement
 
float _horizontalMovementForce
 
float _normalizedHorizontalSpeed
 
float _lastTimeGrounded = 0f
 
float _initialMovementSpeedMultiplier
 
int _speedAnimationParameter
 
int _walkingAnimationParameter
 
int _relativeSpeedAnimationParameter
 
- Protected Attributes inherited from MoreMountains.CorgiEngine.CharacterAbility
Character _character
 
Transform _characterTransform
 
Health _health
 
CharacterHorizontalMovement _characterHorizontalMovement
 
CorgiController _controller
 
InputManager _inputManager
 
CameraController _sceneCamera
 
Animator _animator
 
CharacterStates _state
 
SpriteRenderer _spriteRenderer
 
MMStateMachine< CharacterStates.MovementStates_movement
 
MMStateMachine< CharacterStates.CharacterConditions_condition
 
bool _abilityInitialized = false
 
CharacterGravity _characterGravity
 
float _verticalInput
 
float _horizontalInput
 
bool _startFeedbackIsPlaying = false
 
List< CharacterHandleWeapon_handleWeaponList
 

Static Protected Attributes

const string _speedAnimationParameterName = "Speed"
 
const string _relativeSpeedAnimationParameterName = "xSpeedFacing"
 
const string _walkingAnimationParameterName = "Walking"
 

Properties

float MovementSpeed [get, set]
 the current reference movement speed More...
 
virtual float HorizontalMovementForce [get]
 the current horizontal movement force More...
 
virtual bool MovementForbidden [get, set]
 if this is true, movement will be forbidden (as well as flip) More...
 
- Properties inherited from MoreMountains.CorgiEngine.CharacterAbility
virtual bool AbilityAuthorized [get]
 
virtual bool AbilityInitialized [get]
 true if the ability has already been initialized More...
 

Detailed Description

Add this ability to a Character to have it handle horizontal movement (walk, and potentially run, crawl, etc) Animator parameters : Speed (float), Walking (bool)

Member Function Documentation

◆ ApplyContextSpeedMultiplier()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.ApplyContextSpeedMultiplier ( float  movementMultiplier,
float  duration 
)
virtual

Applies a movement multiplier for the specified duration

Parameters
movementMultiplier
duration

◆ ApplyContextSpeedMultiplierCo()

virtual IEnumerator MoreMountains.CorgiEngine.CharacterHorizontalMovement.ApplyContextSpeedMultiplierCo ( 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.CorgiEngine.CharacterHorizontalMovement.CheckJustGotGrounded ( )
protectedvirtual

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

◆ DetectWalls()

virtual bool MoreMountains.CorgiEngine.CharacterHorizontalMovement.DetectWalls ( bool  changeState)
protectedvirtual

This method will return true if a wall is detected in front of the character, false otherwise

Parameters
changeStateWhether or not this method should change state to idle if a wall is found
Returns

◆ HandleFriction()

virtual float MoreMountains.CorgiEngine.CharacterHorizontalMovement.HandleFriction ( float  force)
protectedvirtual

Handles surface friction.

Returns
The modified current force.
Parameters
forcethe force we want to apply friction to.

◆ HandleHorizontalMovement()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.HandleHorizontalMovement ( )
protectedvirtual

Called at Update(), handles horizontal movement

if we're dashing, we stop there

◆ HandleInput()

override void MoreMountains.CorgiEngine.CharacterHorizontalMovement.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.CorgiEngine.CharacterAbility.

◆ HelpBoxText()

override string MoreMountains.CorgiEngine.CharacterHorizontalMovement.HelpBoxText ( )
virtual

This method is only used to display a helpbox text at the beginning of the ability's inspector.

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ Initialization()

override void MoreMountains.CorgiEngine.CharacterHorizontalMovement.Initialization ( )
protectedvirtual

On Initialization, we set our movement speed to WalkSpeed.

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ InitializeAnimatorParameters()

override void MoreMountains.CorgiEngine.CharacterHorizontalMovement.InitializeAnimatorParameters ( )
protectedvirtual

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

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ OnDisable()

override void MoreMountains.CorgiEngine.CharacterHorizontalMovement.OnDisable ( )
protectedvirtual

On disable, we stop listening for OnRevive events

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ OnEnable()

override void MoreMountains.CorgiEngine.CharacterHorizontalMovement.OnEnable ( )
protectedvirtual

When the player respawns, we reinstate this agent.

Parameters
checkpointCheckpoint.
playerPlayer.

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ OnRevive()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.OnRevive ( )
protectedvirtual

When the character gets revived we reinit it again

◆ ProcessAbility()

override void MoreMountains.CorgiEngine.CharacterHorizontalMovement.ProcessAbility ( )
virtual

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

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ ResetContextSpeedMultiplier()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.ResetContextSpeedMultiplier ( )
virtual

Revers the context speed multiplier to its previous value

◆ ResetHorizontalSpeed()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.ResetHorizontalSpeed ( )
virtual

A public method to reset the horizontal speed

◆ ResetMovementSpeedMultiplier()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.ResetMovementSpeedMultiplier ( )
virtual

Resets the current movement multiplier to its initial value

◆ SetAirControlDirection()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.SetAirControlDirection ( float  newInputValue)
virtual

When using low (or null) air control, this method lets you externally set the direction air control should consider as the base value

Parameters
newInputValue

◆ SetContextSpeedMultiplier()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.SetContextSpeedMultiplier ( float  newMovementSpeedMultiplier)
virtual

Stacks a new context speed multiplier

Parameters
newMovementSpeedMultiplier

◆ SetHorizontalMove()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.SetHorizontalMove ( float  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

◆ StoreLastTimeGrounded()

virtual void MoreMountains.CorgiEngine.CharacterHorizontalMovement.StoreLastTimeGrounded ( )
protectedvirtual

Computes and stores the last time we were grounded

◆ UpdateAnimator()

override void MoreMountains.CorgiEngine.CharacterHorizontalMovement.UpdateAnimator ( )
virtual

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

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

Member Data Documentation

◆ _horizontalMovement

float MoreMountains.CorgiEngine.CharacterHorizontalMovement._horizontalMovement
protected

◆ _horizontalMovementForce

float MoreMountains.CorgiEngine.CharacterHorizontalMovement._horizontalMovementForce
protected

◆ _initialMovementSpeedMultiplier

float MoreMountains.CorgiEngine.CharacterHorizontalMovement._initialMovementSpeedMultiplier
protected

◆ _lastGroundedHorizontalMovement

float MoreMountains.CorgiEngine.CharacterHorizontalMovement._lastGroundedHorizontalMovement
protected

◆ _lastTimeGrounded

float MoreMountains.CorgiEngine.CharacterHorizontalMovement._lastTimeGrounded = 0f
protected

◆ _normalizedHorizontalSpeed

float MoreMountains.CorgiEngine.CharacterHorizontalMovement._normalizedHorizontalSpeed
protected

◆ _relativeSpeedAnimationParameter

int MoreMountains.CorgiEngine.CharacterHorizontalMovement._relativeSpeedAnimationParameter
protected

◆ _relativeSpeedAnimationParameterName

const string MoreMountains.CorgiEngine.CharacterHorizontalMovement._relativeSpeedAnimationParameterName = "xSpeedFacing"
staticprotected

◆ _speedAnimationParameter

int MoreMountains.CorgiEngine.CharacterHorizontalMovement._speedAnimationParameter
protected

◆ _speedAnimationParameterName

const string MoreMountains.CorgiEngine.CharacterHorizontalMovement._speedAnimationParameterName = "Speed"
staticprotected

◆ _walkingAnimationParameter

int MoreMountains.CorgiEngine.CharacterHorizontalMovement._walkingAnimationParameter
protected

◆ _walkingAnimationParameterName

const string MoreMountains.CorgiEngine.CharacterHorizontalMovement._walkingAnimationParameterName = "Walking"
staticprotected

◆ AbilityMovementSpeedMultiplier

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.AbilityMovementSpeedMultiplier = 1f

the multiplier to apply to the horizontal movement, dedicated to abilities

◆ ActiveAfterDeath

bool MoreMountains.CorgiEngine.CharacterHorizontalMovement.ActiveAfterDeath = false

whether or not this ability should keep taking care of horizontal movement after death

◆ AirControl

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.AirControl = 1f

how much air control the player has

◆ AllowFlipInTheAir

bool MoreMountains.CorgiEngine.CharacterHorizontalMovement.AllowFlipInTheAir = true

whether or not the player can flip in the air

◆ ContextSpeedMultiplier

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.ContextSpeedMultiplier => ContextSpeedStack.Count > 0 ? ContextSpeedStack.Peek() : 1

◆ ContextSpeedStack

Stack<float> MoreMountains.CorgiEngine.CharacterHorizontalMovement.ContextSpeedStack = new Stack<float>()

◆ FlipCharacterToFaceDirection

bool MoreMountains.CorgiEngine.CharacterHorizontalMovement.FlipCharacterToFaceDirection = true

if this is true, the character will automatically flip to face its movement direction

◆ InputThreshold

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.InputThreshold = 0.1f

the threshold after which input is considered (usually 0.1f to eliminate small joystick noise)

◆ InstantAcceleration

bool MoreMountains.CorgiEngine.CharacterHorizontalMovement.InstantAcceleration = false

if this is true, no acceleration will be applied to the movement, which will instantly be full speed (think Megaman movement). Attention : a character with instant acceleration won't be able to get knockbacked on the x axis as a regular character would, it's a tradeoff

◆ MinimumAirTimeBeforeFeedback

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.MinimumAirTimeBeforeFeedback = 0.2f

the duration (in seconds) during which the character has to be airborne before a feedback can be played when touching the ground

◆ MovementSpeedMultiplier

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.MovementSpeedMultiplier = 1f

the multiplier to apply to the horizontal movement

◆ PushSpeedMultiplier

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.PushSpeedMultiplier = 1f

the multiplier to apply when pushing

◆ ReadInput

bool MoreMountains.CorgiEngine.CharacterHorizontalMovement.ReadInput = true

if this is true, will get input from an input source, otherwise you'll have to set it via SetHorizontalMove()

◆ ResetHorizontalSpeedBtn

bool MoreMountains.CorgiEngine.CharacterHorizontalMovement.ResetHorizontalSpeedBtn

press this debug button if you decide to change the WalkSpeed at runtime, to reset its cache and have it impact your character in real time

◆ StateSpeedMultiplier

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.StateSpeedMultiplier = 1f

the multiplier that gets set and applied by CharacterSpeed

◆ StopWalkingWhenCollidingWithAWall

bool MoreMountains.CorgiEngine.CharacterHorizontalMovement.StopWalkingWhenCollidingWithAWall = false

Whether or not the state should be reset to Idle when colliding laterally with a wall.

◆ TouchTheGroundFeedback

MMFeedbacks MoreMountains.CorgiEngine.CharacterHorizontalMovement.TouchTheGroundFeedback

the MMFeedbacks to play when the character hits the ground

◆ WalkSpeed

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.WalkSpeed = 6f

the speed of the character when it's walking

Property Documentation

◆ HorizontalMovementForce

virtual float MoreMountains.CorgiEngine.CharacterHorizontalMovement.HorizontalMovementForce
get

the current horizontal movement force

◆ MovementForbidden

virtual bool MoreMountains.CorgiEngine.CharacterHorizontalMovement.MovementForbidden
getset

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

◆ MovementSpeed

float MoreMountains.CorgiEngine.CharacterHorizontalMovement.MovementSpeed
getset

the current reference movement speed


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