Corgi Engine  v8.8
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< CorgiEngineEvent > MoreMountains.CorgiEngine.CorgiMonoBehaviour

Public Types

enum  TransitionForcesModes { TransitionForcesModes.Reset, TransitionForcesModes.Adapt, TransitionForcesModes.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. More...
 
virtual void Update ()
 On process we draw debug and rotate our character if needed More...
 
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). More...
 
virtual bool ShouldReverseInput ()
 Returns true if conditions to reverse input are met More...
 
virtual void SetGravityAngle (float newAngle)
 Sets the default gravity angle to the one specified in parameters More...
 
virtual void ResetGravityToDefault ()
 Resets the gravity to its default value. More...
 
override void ResetAbility ()
 On reset ability, we cancel all the changes made More...
 
virtual void OnMMEvent (CorgiEngineEvent engineEvent)
 When we get a Corgi Engine event, we act on it 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 ProcessAbility ()
 The second of the 3 passes you can have in your ability. Think of it as Update() More...
 
virtual void LateProcessAbility ()
 The last of the 3 passes you can have in your ability. Think of it as LateUpdate() More...
 
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(). 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 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 Member Functions inherited from MoreMountains.Tools.MMEventListener< CorgiEngineEvent >
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. More...
 
bool SubjectToGravityZones = true
 If this is true, this Character will have its gravity affected when crossing Gravity Zones. More...
 
bool ReverseHorizontalInputWhenUpsideDown = false
 if this is true, horizontal movement input will be reversed when upside down More...
 
bool ReverseVerticalInputWhenUpsideDown = false
 if this is true, vertical movement input will be reversed when upside down More...
 
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 More...
 
float InitialGravityAngle = 0f
 the initial gravity angle, that's the gravity angle your character will start at More...
 
float RotationSpeed = 0f
 the speed at which the Character rotates to match its new gravity's rotation. 0 means instant. More...
 
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. More...
 
TransitionForcesModes TransitionForcesMode = TransitionForcesModes.Reset
 if this is set to true, forces will be reset when entering/exiting gravity zones. More...
 
bool ResetCharacterStateOnGravityChange = true
 if this is true, the character state will be reset to idle when entering the zone More...
 
bool DrawDebugGravityArrow = true
 If this is true, will draw an arrow showing the current target gravity direction. More...
 
- 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 rotate our character to match the initial gravity angle and store it More...
 
virtual void CleanGravityZones ()
 Safety measures to make sure we aren't applying the wrong gravity at any given time More...
 
virtual void ComputeGravityPoints ()
 Finds the closest gravity point and changes the gravity if needed More...
 
virtual GravityPoint GetClosestGravityPoint ()
 Gets the closest gravity point out of all the ones stored in the GravityPoints array More...
 
virtual void UpdateGravity ()
 Rotates the Character to match the current target gravity angle More...
 
virtual void OnTriggerEnter2D (Collider2D collider)
 When entering a zone, checks if it's a Gravity Zone, and if yes, sets gravity accordingly More...
 
virtual void OnTriggerExit2D (Collider2D collider)
 When exiting a zone, checks if it was a Gravity Zone, and if yes, resets gravity accordingly More...
 
virtual void SetGravityZone (GravityZone gravityZone)
 Sets the specified gravity zone as the current one, applying its gravity properties to our character More...
 
virtual void ExitGravityZone (GravityZone gravityZone)
 When exiting a gravity zone we reset our gravity and handle transition More...
 
virtual void StartRotating ()
 Triggers the need to rotate the character More...
 
virtual void Transition (bool entering, Vector2 gravityDirection)
 Handles the existing forces on a character when entering/exiting a zone More...
 
override void OnRespawn ()
 This gets called when the player dies More...
 
virtual void DrawGravityDebug ()
 If authorized to, draws a debug arrow showing the direction of the current target gravity More...
 
override void OnEnable ()
 On enable we start listening for events More...
 
virtual void OnDestroy ()
 On disable we stop listening for events More...
 
- Protected Member Functions inherited from MoreMountains.CorgiEngine.CharacterAbility
virtual void Start ()
 On Start(), we call the ability's intialization More...
 
virtual void InitializeAnimatorParameters ()
 Adds required animator parameters to the animator parameters list if they exist More...
 
virtual void InternalHandleInput ()
 Internal method to check if an input manager is present or not More...
 
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 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...
 
virtual void OnDisable ()
 On disable, we unbind our respawn delegate More...
 

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
 
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 float _rotationSpeedMultiplier = 1000f
 

Properties

virtual float? GravityAngle [get]
 the current target gravity angle More...
 
virtual Vector2 GravityDirectionVector [get]
 the current target gravity vector More...
 
virtual bool InGravityPointRange [get, set]
 true while the Character is affected by a gravity point 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 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: