Corgi Engine v10.0
Loading...
Searching...
No Matches
MoreMountains.CorgiEngine.CharacterGravity Class Reference

Add this class to a character and it'll be able to have a different gravity than the default one, and will be able to change it via Gravity Zones and Gravity Points Animator parameters : none. More...

Inheritance diagram for MoreMountains.CorgiEngine.CharacterGravity:
MoreMountains.CorgiEngine.CharacterAbility MoreMountains.Tools.MMEventListener< T > MoreMountains.CorgiEngine.CorgiMonoBehaviour MoreMountains.Tools.MMEventListenerBase

Public Types

enum  TransitionForcesModes { Reset , Adapt , Nothing }
 the various ways you can modify the existing character forces when entering or exiting a gravity zone. Reset will set them at 0, Nothing will do nothing (use at your own risk), and Adapt will rotate the force to match the new gravity More...

Public Member Functions

override string HelpBoxText ()
 This method is only used to display a helpbox text at the beginning of the ability's inspector.
virtual void Update ()
 On process we draw debug and rotate our character if needed.
virtual void UpdateGravityPointsList ()
 Called at Init, this grabs all the Gravity Points in the scene and stores them. You can also call this method if you decide to add gravity points at runtime to refresh the list (they'll be ignored otherwise).
virtual bool ShouldReverseInput ()
 Returns true if conditions to reverse input are met.
virtual void SetGravityAngle (float newAngle)
 Sets the default gravity angle to the one specified in parameters.
virtual void ResetGravityToDefault ()
 Resets the gravity to its default value.
override void ResetAbility ()
 On reset ability, we cancel all the changes made.
virtual void OnMMEvent (CorgiEngineEvent engineEvent)
 When we get a Corgi Engine event, we act on it.
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.
virtual void BindAnimator ()
 Binds the animator from the character and initializes the animator parameters.
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 ProcessAbility ()
 The second of the 3 passes you can have in your ability. Think of it as Update()
virtual void LateProcessAbility ()
 The last of the 3 passes you can have in your ability. Think of it as LateUpdate()
virtual void UpdateAnimator ()
 Override this to send parameters to the character's animator. This is called once per cycle, by the Character class, after Early, normal and Late process().
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 PlayAbilityStartFeedbacks ()
 Plays the ability start feedback.
virtual void StopStartFeedbacks ()
 Stops the ability used feedback.
virtual void PlayAbilityStopFeedbacks ()
 Plays the ability stop feedback.
virtual void RegisterAnimatorParameter (string parameterName, AnimatorControllerParameterType parameterType, out int parameter)
 Registers a new animator parameter to the list.
Public Member Functions inherited from MoreMountains.Tools.MMEventListener< T >
void OnMMEvent (T eventType)

Public Attributes

bool SubjectToGravityPoints = true
 If this is true, this Character's gravity will be overridden when close to Gravity Points.
bool SubjectToGravityZones = true
 If this is true, this Character will have its gravity affected when crossing Gravity Zones.
bool ReverseHorizontalInputWhenUpsideDown = false
 if this is true, horizontal movement input will be reversed when upside down
bool ReverseVerticalInputWhenUpsideDown = false
 if this is true, vertical movement input will be reversed when upside down
bool ReverseInputOnGravityPoints = false
 if this is false, input won't be reversed while on a gravity point (you'll usually want to keep it false so you can run around the point
float InitialGravityAngle = 0f
 the initial gravity angle, that's the gravity angle your character will start at
float RotationSpeed = 0f
 the speed at which the Character rotates to match its new gravity's rotation. 0 means instant.
float InactiveBufferDuration = 0.1f
 the duration (in seconds) during which a zone is ignored when entered/exited, right after the enter/exit, to accomodate for rotation times. If you have a slow rotation speed, increase this.
TransitionForcesModes TransitionForcesMode = TransitionForcesModes.Reset
 if this is set to true, forces will be reset when entering/exiting gravity zones.
bool ResetCharacterStateOnGravityChange = true
 if this is true, the character state will be reset to idle when entering the zone
bool DrawDebugGravityArrow = true
 If this is true, will draw an arrow showing the current target gravity direction.
Public Attributes inherited from MoreMountains.CorgiEngine.CharacterAbility
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.

Protected Member Functions

override void Initialization ()
 On Initialization, we rotate our character to match the initial gravity angle and store it.
virtual void CleanGravityZones ()
 Safety measures to make sure we aren't applying the wrong gravity at any given time.
virtual void ComputeGravityPoints ()
 Finds the closest gravity point and changes the gravity if needed.
virtual GravityPoint GetClosestGravityPoint ()
 Gets the closest gravity point out of all the ones stored in the GravityPoints array.
virtual void UpdateGravity ()
 Rotates the Character to match the current target gravity angle.
virtual void OnTriggerEnter2D (Collider2D collider)
 When entering a zone, checks if it's a Gravity Zone, and if yes, sets gravity accordingly.
virtual void OnTriggerExit2D (Collider2D collider)
 When exiting a zone, checks if it was a Gravity Zone, and if yes, resets gravity accordingly.
virtual void SetGravityZone (GravityZone gravityZone)
 Sets the specified gravity zone as the current one, applying its gravity properties to our character.
virtual void ExitGravityZone (GravityZone gravityZone)
 When exiting a gravity zone we reset our gravity and handle transition.
virtual void StartRotating ()
 Triggers the need to rotate the character.
virtual void Transition (bool entering, Vector2 gravityDirection)
 Handles the existing forces on a character when entering/exiting a zone.
override void OnRespawn ()
 This gets called when the player dies.
virtual void DrawGravityDebug ()
 If authorized to, draws a debug arrow showing the direction of the current target gravity.
override void OnEnable ()
 On enable we start listening for events.
virtual void OnDestroy ()
 On disable we stop listening for events.
Protected Member Functions inherited from MoreMountains.CorgiEngine.CharacterAbility
virtual void Start ()
 On Start(), we call the ability's intialization.
virtual void InitializeAnimatorParameters ()
 Adds required animator parameters to the animator parameters list if they exist.
virtual void InternalHandleInput ()
 Internal method to check if an input manager is present or not.
virtual 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 void OnDeath ()
 Override this to describe what should happen to this ability when the character respawns.
virtual void OnHit ()
 Override this to describe what should happen to this ability when the character takes a hit.
virtual void OnDisable ()
 On disable, we unbind our respawn delegate.

Protected Attributes

List< GravityPoint > _gravityPoints
GravityPoint _closestGravityPoint = null
Vector2 _gravityPointDirection = Vector2.zero
bool _inAGravityZone = false
GravityZone _currentGravityZone = null
float _defaultGravityAngle = 0f
float _currentGravityAngle
float _overrideGravityAngle = 0f
bool _gravityOverridden = false
float _rotationDirection = 0f
Vector3 _newRotationAngle = Vector3.zero
float _entryTimeStampZones = 0f
float _entryTimeStampPoints = 0f
GravityPoint _lastGravityPoint = null
GravityPoint _newGravityPoint = null
float _previousGravityAngle
GravityZone _cachedGravityZone = null
CharacterDash _characterDash
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
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 float _rotationSpeedMultiplier = 1000f

Properties

virtual float GravityAngle [get]
 the current target gravity angle
virtual Vector2 GravityDirectionVector [get]
 the current target gravity vector
virtual bool InGravityPointRange [get, set]
 true while the Character is affected by a gravity point
Properties inherited from MoreMountains.CorgiEngine.CharacterAbility
virtual bool AbilityAuthorized [get]
virtual bool AbilityInitialized [get]
 true if the ability has already been initialized

Detailed Description

Add this class to a character and it'll be able to have a different gravity than the default one, and will be able to change it via Gravity Zones and Gravity Points Animator parameters : none.

Member Enumeration Documentation

◆ TransitionForcesModes

the various ways you can modify the existing character forces when entering or exiting a gravity zone. Reset will set them at 0, Nothing will do nothing (use at your own risk), and Adapt will rotate the force to match the new gravity

Enumerator
Reset 
Adapt 
Nothing 

Member Function Documentation

◆ CleanGravityZones()

virtual void MoreMountains.CorgiEngine.CharacterGravity.CleanGravityZones ( )
protectedvirtual

Safety measures to make sure we aren't applying the wrong gravity at any given time.

◆ ComputeGravityPoints()

virtual void MoreMountains.CorgiEngine.CharacterGravity.ComputeGravityPoints ( )
protectedvirtual

Finds the closest gravity point and changes the gravity if needed.

◆ DrawGravityDebug()

virtual void MoreMountains.CorgiEngine.CharacterGravity.DrawGravityDebug ( )
protectedvirtual

If authorized to, draws a debug arrow showing the direction of the current target gravity.

◆ ExitGravityZone()

virtual void MoreMountains.CorgiEngine.CharacterGravity.ExitGravityZone ( GravityZone gravityZone)
protectedvirtual

When exiting a gravity zone we reset our gravity and handle transition.

Parameters
gravityZoneGravity zone.

◆ GetClosestGravityPoint()

virtual GravityPoint MoreMountains.CorgiEngine.CharacterGravity.GetClosestGravityPoint ( )
protectedvirtual

Gets the closest gravity point out of all the ones stored in the GravityPoints array.

Returns
The closest gravity point.

◆ HelpBoxText()

override string MoreMountains.CorgiEngine.CharacterGravity.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.CharacterGravity.Initialization ( )
protectedvirtual

On Initialization, we rotate our character to match the initial gravity angle and store it.

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ OnDestroy()

virtual void MoreMountains.CorgiEngine.CharacterGravity.OnDestroy ( )
protectedvirtual

On disable we stop listening for events.

◆ OnEnable()

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

On enable we start listening for events.

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ OnMMEvent()

virtual void MoreMountains.CorgiEngine.CharacterGravity.OnMMEvent ( CorgiEngineEvent engineEvent)
virtual

When we get a Corgi Engine event, we act on it.

Parameters
gameEvent

◆ OnRespawn()

override void MoreMountains.CorgiEngine.CharacterGravity.OnRespawn ( )
protectedvirtual

This gets called when the player dies.

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ OnTriggerEnter2D()

virtual void MoreMountains.CorgiEngine.CharacterGravity.OnTriggerEnter2D ( Collider2D collider)
protectedvirtual

When entering a zone, checks if it's a Gravity Zone, and if yes, sets gravity accordingly.

Parameters
colliderCollider.

◆ OnTriggerExit2D()

virtual void MoreMountains.CorgiEngine.CharacterGravity.OnTriggerExit2D ( Collider2D collider)
protectedvirtual

When exiting a zone, checks if it was a Gravity Zone, and if yes, resets gravity accordingly.

Parameters
colliderCollider.

◆ ResetAbility()

override void MoreMountains.CorgiEngine.CharacterGravity.ResetAbility ( )
virtual

On reset ability, we cancel all the changes made.

Reimplemented from MoreMountains.CorgiEngine.CharacterAbility.

◆ ResetGravityToDefault()

virtual void MoreMountains.CorgiEngine.CharacterGravity.ResetGravityToDefault ( )
virtual

Resets the gravity to its default value.

◆ SetGravityAngle()

virtual void MoreMountains.CorgiEngine.CharacterGravity.SetGravityAngle ( float newAngle)
virtual

Sets the default gravity angle to the one specified in parameters.

Parameters
newAngleNew angle.

◆ SetGravityZone()

virtual void MoreMountains.CorgiEngine.CharacterGravity.SetGravityZone ( GravityZone gravityZone)
protectedvirtual

Sets the specified gravity zone as the current one, applying its gravity properties to our character.

Parameters
gravityZoneGravity zone.

◆ ShouldReverseInput()

virtual bool MoreMountains.CorgiEngine.CharacterGravity.ShouldReverseInput ( )
virtual

Returns true if conditions to reverse input are met.

Returns
true, if reverse input was shoulded, false otherwise.

◆ StartRotating()

virtual void MoreMountains.CorgiEngine.CharacterGravity.StartRotating ( )
protectedvirtual

Triggers the need to rotate the character.

◆ Transition()

virtual void MoreMountains.CorgiEngine.CharacterGravity.Transition ( bool entering,
Vector2 gravityDirection )
protectedvirtual

Handles the existing forces on a character when entering/exiting a zone.

Parameters
enteringIf set to true entering.
gravityDirectionGravity direction.

◆ Update()

virtual void MoreMountains.CorgiEngine.CharacterGravity.Update ( )
virtual

On process we draw debug and rotate our character if needed.

◆ UpdateGravity()

virtual void MoreMountains.CorgiEngine.CharacterGravity.UpdateGravity ( )
protectedvirtual

Rotates the Character to match the current target gravity angle.

◆ UpdateGravityPointsList()

virtual void MoreMountains.CorgiEngine.CharacterGravity.UpdateGravityPointsList ( )
virtual

Called at Init, this grabs all the Gravity Points in the scene and stores them. You can also call this method if you decide to add gravity points at runtime to refresh the list (they'll be ignored otherwise).

Member Data Documentation

◆ _cachedGravityZone

GravityZone MoreMountains.CorgiEngine.CharacterGravity._cachedGravityZone = null
protected

◆ _characterDash

CharacterDash MoreMountains.CorgiEngine.CharacterGravity._characterDash
protected

◆ _closestGravityPoint

GravityPoint MoreMountains.CorgiEngine.CharacterGravity._closestGravityPoint = null
protected

◆ _currentGravityAngle

float MoreMountains.CorgiEngine.CharacterGravity._currentGravityAngle
protected

◆ _currentGravityZone

GravityZone MoreMountains.CorgiEngine.CharacterGravity._currentGravityZone = null
protected

◆ _defaultGravityAngle

float MoreMountains.CorgiEngine.CharacterGravity._defaultGravityAngle = 0f
protected

◆ _entryTimeStampPoints

float MoreMountains.CorgiEngine.CharacterGravity._entryTimeStampPoints = 0f
protected

◆ _entryTimeStampZones

float MoreMountains.CorgiEngine.CharacterGravity._entryTimeStampZones = 0f
protected

◆ _gravityOverridden

bool MoreMountains.CorgiEngine.CharacterGravity._gravityOverridden = false
protected

◆ _gravityPointDirection

Vector2 MoreMountains.CorgiEngine.CharacterGravity._gravityPointDirection = Vector2.zero
protected

◆ _gravityPoints

List<GravityPoint> MoreMountains.CorgiEngine.CharacterGravity._gravityPoints
protected

◆ _inAGravityZone

bool MoreMountains.CorgiEngine.CharacterGravity._inAGravityZone = false
protected

◆ _lastGravityPoint

GravityPoint MoreMountains.CorgiEngine.CharacterGravity._lastGravityPoint = null
protected

◆ _newGravityPoint

GravityPoint MoreMountains.CorgiEngine.CharacterGravity._newGravityPoint = null
protected

◆ _newRotationAngle

Vector3 MoreMountains.CorgiEngine.CharacterGravity._newRotationAngle = Vector3.zero
protected

◆ _overrideGravityAngle

float MoreMountains.CorgiEngine.CharacterGravity._overrideGravityAngle = 0f
protected

◆ _previousGravityAngle

float MoreMountains.CorgiEngine.CharacterGravity._previousGravityAngle
protected

◆ _rotationDirection

float MoreMountains.CorgiEngine.CharacterGravity._rotationDirection = 0f
protected

◆ _rotationSpeedMultiplier

const float MoreMountains.CorgiEngine.CharacterGravity._rotationSpeedMultiplier = 1000f
staticprotected

◆ DrawDebugGravityArrow

bool MoreMountains.CorgiEngine.CharacterGravity.DrawDebugGravityArrow = true

If this is true, will draw an arrow showing the current target gravity direction.

◆ InactiveBufferDuration

float MoreMountains.CorgiEngine.CharacterGravity.InactiveBufferDuration = 0.1f

the duration (in seconds) during which a zone is ignored when entered/exited, right after the enter/exit, to accomodate for rotation times. If you have a slow rotation speed, increase this.

◆ InitialGravityAngle

float MoreMountains.CorgiEngine.CharacterGravity.InitialGravityAngle = 0f

the initial gravity angle, that's the gravity angle your character will start at

◆ ResetCharacterStateOnGravityChange

bool MoreMountains.CorgiEngine.CharacterGravity.ResetCharacterStateOnGravityChange = true

if this is true, the character state will be reset to idle when entering the zone

◆ ReverseHorizontalInputWhenUpsideDown

bool MoreMountains.CorgiEngine.CharacterGravity.ReverseHorizontalInputWhenUpsideDown = false

if this is true, horizontal movement input will be reversed when upside down

◆ ReverseInputOnGravityPoints

bool MoreMountains.CorgiEngine.CharacterGravity.ReverseInputOnGravityPoints = false

if this is false, input won't be reversed while on a gravity point (you'll usually want to keep it false so you can run around the point

◆ ReverseVerticalInputWhenUpsideDown

bool MoreMountains.CorgiEngine.CharacterGravity.ReverseVerticalInputWhenUpsideDown = false

if this is true, vertical movement input will be reversed when upside down

◆ RotationSpeed

float MoreMountains.CorgiEngine.CharacterGravity.RotationSpeed = 0f

the speed at which the Character rotates to match its new gravity's rotation. 0 means instant.

◆ SubjectToGravityPoints

bool MoreMountains.CorgiEngine.CharacterGravity.SubjectToGravityPoints = true

If this is true, this Character's gravity will be overridden when close to Gravity Points.

◆ SubjectToGravityZones

bool MoreMountains.CorgiEngine.CharacterGravity.SubjectToGravityZones = true

If this is true, this Character will have its gravity affected when crossing Gravity Zones.

◆ TransitionForcesMode

TransitionForcesModes MoreMountains.CorgiEngine.CharacterGravity.TransitionForcesMode = TransitionForcesModes.Reset

if this is set to true, forces will be reset when entering/exiting gravity zones.

Property Documentation

◆ GravityAngle

virtual float MoreMountains.CorgiEngine.CharacterGravity.GravityAngle
get

the current target gravity angle

◆ GravityDirectionVector

virtual Vector2 MoreMountains.CorgiEngine.CharacterGravity.GravityDirectionVector
get

the current target gravity vector

◆ InGravityPointRange

virtual bool MoreMountains.CorgiEngine.CharacterGravity.InGravityPointRange
getset

true while the Character is affected by a gravity point


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