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

Add this ability to a character and it'll rotate or flip to face the direction of movement or the weapon's, or both, or none Only add this ability to a 2D character. More...

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

Public Types

enum  RotationModes { None , MovementDirection , WeaponDirection , Both }
 the possible rotation modes More...
enum  RotationSpeeds { Instant , Smooth , SmoothAbsolute }
 the possible rotation speeds More...

Public Member Functions

override void ProcessAbility ()
 Every frame we rotate towards the direction.
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 ResetAbility ()
 Override this to reset this ability's parameters. It'll be automatically called when the character gets killed, in anticipation for its respawn.
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

RotationModes RotationMode = RotationModes.None
 whether the character should face movement direction, weapon direction, or both, or none
bool ForcedRotation = false
 whether the character is being applied a forced rotation
Vector3 ForcedRotationDirection
 the forced rotation applied by an external script
bool ForcedRotationImpactsWeapon
 whether or not the forced rotation should impact weapon direction
bool ShouldRotateToFaceMovementDirection = true
 If this is true, we'll rotate our model towards the direction.
RotationSpeeds MovementRotationSpeed = RotationSpeeds.Instant
 the current rotation mode
GameObject MovementRotatingModel
 the object we want to rotate towards direction. If left empty, we'll use the Character's model
float RotateToFaceMovementDirectionSpeed = 10f
 the speed at which to rotate towards direction (smooth and absolute only)
float AbsoluteThresholdMovement = 0.5f
 the threshold after which we start rotating (absolute mode only)
Vector3 ModelDirection
 the direction of the model
Vector3 ModelAngles
 the direction of the model in angle values
bool ShouldRotateToFaceWeaponDirection = true
 If this is true, we'll rotate our model towards the weapon's direction.
RotationSpeeds WeaponRotationSpeed = RotationSpeeds.Instant
 the current rotation mode
GameObject WeaponRotatingModel
 the object we want to rotate towards direction. If left empty, we'll use the Character's model
float RotateToFaceWeaponDirectionSpeed = 10f
 the speed at which to rotate towards direction (smooth and absolute only)
float AbsoluteThresholdWeapon = 0.5f
 the threshold after which we start rotating (absolute mode only)
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 init we grab our model if necessary.
virtual void FixedUpdate ()
virtual void RotateToFaceMovementDirection ()
 Rotates the player model to face the current direction.
virtual void RotateToFaceWeaponDirection ()
 Rotates the character so it faces the weapon's direction.
virtual void RotateToFaceForcedRotation ()
 If we have a forced rotation, we apply it.
virtual void RotateModel ()
 Rotates models if needed.
virtual void ComputeRelativeSpeeds ()
 Computes the relative speeds.
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 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 RegisterAnimatorParameter (string parameterName, AnimatorControllerParameterType parameterType, out int parameter)
 Registers a new animator parameter to the list.
virtual void OnRespawn ()
 Override this to describe what should happen to this ability when the character respawns.
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 OnEnable ()
 On enable, we bind our respawn delegate.
virtual void OnDisable ()
 On disable, we unbind our respawn delegate.

Protected Attributes

CharacterHandleWeapon _characterHandleWeapon
Vector3 _lastRegisteredVelocity
Vector3 _rotationDirection
Vector3 _lastMovement = Vector3.zero
Vector3 _lastAim = Vector3.zero
Vector3 _relativeSpeed
Vector3 _relativeSpeedNormalized
bool _secondaryMovementTriggered = false
Quaternion _tmpRotation
Quaternion _newMovementQuaternion
Quaternion _newWeaponQuaternion
bool _shouldRotateTowardsWeapon
int _relativeForwardSpeedAnimationParameter
int _relativeLateralSpeedAnimationParameter
int _relativeForwardSpeedNormalizedAnimationParameter
int _relativeLateralSpeedNormalizedAnimationParameter
Vector3 _positionLastFrame
Vector3 _newSpeed
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 _relativeForwardSpeedAnimationParameterName = "RelativeForwardSpeed"
const string _relativeLateralSpeedAnimationParameterName = "RelativeLateralSpeed"
const string _relativeForwardSpeedNormalizedAnimationParameterName = "RelativeForwardSpeedNormalized"
const string _relativeLateralSpeedNormalizedAnimationParameterName = "RelativeLateralSpeedNormalized"

Additional Inherited Members

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 and it'll rotate or flip to face the direction of movement or the weapon's, or both, or none Only add this ability to a 2D character.

Member Enumeration Documentation

◆ RotationModes

the possible rotation modes

Enumerator
None 
MovementDirection 
WeaponDirection 
Both 

◆ RotationSpeeds

the possible rotation speeds

Enumerator
Instant 
Smooth 
SmoothAbsolute 

Member Function Documentation

◆ ComputeRelativeSpeeds()

virtual void MoreMountains.TopDownEngine.CharacterRotation2D.ComputeRelativeSpeeds ( )
protectedvirtual

Computes the relative speeds.

◆ FixedUpdate()

virtual void MoreMountains.TopDownEngine.CharacterRotation2D.FixedUpdate ( )
protectedvirtual

◆ Initialization()

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

On init we grab our model if necessary.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ InitializeAnimatorParameters()

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

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

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ ProcessAbility()

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

Every frame we rotate towards the direction.

Reimplemented from MoreMountains.TopDownEngine.CharacterAbility.

◆ RotateModel()

virtual void MoreMountains.TopDownEngine.CharacterRotation2D.RotateModel ( )
protectedvirtual

Rotates models if needed.

◆ RotateToFaceForcedRotation()

virtual void MoreMountains.TopDownEngine.CharacterRotation2D.RotateToFaceForcedRotation ( )
protectedvirtual

If we have a forced rotation, we apply it.

◆ RotateToFaceMovementDirection()

virtual void MoreMountains.TopDownEngine.CharacterRotation2D.RotateToFaceMovementDirection ( )
protectedvirtual

Rotates the player model to face the current direction.

◆ RotateToFaceWeaponDirection()

virtual void MoreMountains.TopDownEngine.CharacterRotation2D.RotateToFaceWeaponDirection ( )
protectedvirtual

Rotates the character so it faces the weapon's direction.

◆ UpdateAnimator()

override void MoreMountains.TopDownEngine.CharacterRotation2D.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

◆ _characterHandleWeapon

CharacterHandleWeapon MoreMountains.TopDownEngine.CharacterRotation2D._characterHandleWeapon
protected

◆ _lastAim

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D._lastAim = Vector3.zero
protected

◆ _lastMovement

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D._lastMovement = Vector3.zero
protected

◆ _lastRegisteredVelocity

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D._lastRegisteredVelocity
protected

◆ _newMovementQuaternion

Quaternion MoreMountains.TopDownEngine.CharacterRotation2D._newMovementQuaternion
protected

◆ _newSpeed

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D._newSpeed
protected

◆ _newWeaponQuaternion

Quaternion MoreMountains.TopDownEngine.CharacterRotation2D._newWeaponQuaternion
protected

◆ _positionLastFrame

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D._positionLastFrame
protected

◆ _relativeForwardSpeedAnimationParameter

int MoreMountains.TopDownEngine.CharacterRotation2D._relativeForwardSpeedAnimationParameter
protected

◆ _relativeForwardSpeedAnimationParameterName

const string MoreMountains.TopDownEngine.CharacterRotation2D._relativeForwardSpeedAnimationParameterName = "RelativeForwardSpeed"
staticprotected

◆ _relativeForwardSpeedNormalizedAnimationParameter

int MoreMountains.TopDownEngine.CharacterRotation2D._relativeForwardSpeedNormalizedAnimationParameter
protected

◆ _relativeForwardSpeedNormalizedAnimationParameterName

const string MoreMountains.TopDownEngine.CharacterRotation2D._relativeForwardSpeedNormalizedAnimationParameterName = "RelativeForwardSpeedNormalized"
staticprotected

◆ _relativeLateralSpeedAnimationParameter

int MoreMountains.TopDownEngine.CharacterRotation2D._relativeLateralSpeedAnimationParameter
protected

◆ _relativeLateralSpeedAnimationParameterName

const string MoreMountains.TopDownEngine.CharacterRotation2D._relativeLateralSpeedAnimationParameterName = "RelativeLateralSpeed"
staticprotected

◆ _relativeLateralSpeedNormalizedAnimationParameter

int MoreMountains.TopDownEngine.CharacterRotation2D._relativeLateralSpeedNormalizedAnimationParameter
protected

◆ _relativeLateralSpeedNormalizedAnimationParameterName

const string MoreMountains.TopDownEngine.CharacterRotation2D._relativeLateralSpeedNormalizedAnimationParameterName = "RelativeLateralSpeedNormalized"
staticprotected

◆ _relativeSpeed

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D._relativeSpeed
protected

◆ _relativeSpeedNormalized

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D._relativeSpeedNormalized
protected

◆ _rotationDirection

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D._rotationDirection
protected

◆ _secondaryMovementTriggered

bool MoreMountains.TopDownEngine.CharacterRotation2D._secondaryMovementTriggered = false
protected

◆ _shouldRotateTowardsWeapon

bool MoreMountains.TopDownEngine.CharacterRotation2D._shouldRotateTowardsWeapon
protected

◆ _tmpRotation

Quaternion MoreMountains.TopDownEngine.CharacterRotation2D._tmpRotation
protected

◆ AbsoluteThresholdMovement

float MoreMountains.TopDownEngine.CharacterRotation2D.AbsoluteThresholdMovement = 0.5f

the threshold after which we start rotating (absolute mode only)

◆ AbsoluteThresholdWeapon

float MoreMountains.TopDownEngine.CharacterRotation2D.AbsoluteThresholdWeapon = 0.5f

the threshold after which we start rotating (absolute mode only)

◆ ForcedRotation

bool MoreMountains.TopDownEngine.CharacterRotation2D.ForcedRotation = false

whether the character is being applied a forced rotation

◆ ForcedRotationDirection

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D.ForcedRotationDirection

the forced rotation applied by an external script

◆ ForcedRotationImpactsWeapon

bool MoreMountains.TopDownEngine.CharacterRotation2D.ForcedRotationImpactsWeapon

whether or not the forced rotation should impact weapon direction

◆ ModelAngles

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D.ModelAngles

the direction of the model in angle values

◆ ModelDirection

Vector3 MoreMountains.TopDownEngine.CharacterRotation2D.ModelDirection

the direction of the model

◆ MovementRotatingModel

GameObject MoreMountains.TopDownEngine.CharacterRotation2D.MovementRotatingModel

the object we want to rotate towards direction. If left empty, we'll use the Character's model

◆ MovementRotationSpeed

RotationSpeeds MoreMountains.TopDownEngine.CharacterRotation2D.MovementRotationSpeed = RotationSpeeds.Instant

the current rotation mode

◆ RotateToFaceMovementDirectionSpeed

float MoreMountains.TopDownEngine.CharacterRotation2D.RotateToFaceMovementDirectionSpeed = 10f

the speed at which to rotate towards direction (smooth and absolute only)

◆ RotateToFaceWeaponDirectionSpeed

float MoreMountains.TopDownEngine.CharacterRotation2D.RotateToFaceWeaponDirectionSpeed = 10f

the speed at which to rotate towards direction (smooth and absolute only)

◆ RotationMode

RotationModes MoreMountains.TopDownEngine.CharacterRotation2D.RotationMode = RotationModes.None

whether the character should face movement direction, weapon direction, or both, or none

◆ ShouldRotateToFaceMovementDirection

bool MoreMountains.TopDownEngine.CharacterRotation2D.ShouldRotateToFaceMovementDirection = true

If this is true, we'll rotate our model towards the direction.

◆ ShouldRotateToFaceWeaponDirection

bool MoreMountains.TopDownEngine.CharacterRotation2D.ShouldRotateToFaceWeaponDirection = true

If this is true, we'll rotate our model towards the weapon's direction.

◆ WeaponRotatingModel

GameObject MoreMountains.TopDownEngine.CharacterRotation2D.WeaponRotatingModel

the object we want to rotate towards direction. If left empty, we'll use the Character's model

◆ WeaponRotationSpeed

RotationSpeeds MoreMountains.TopDownEngine.CharacterRotation2D.WeaponRotationSpeed = RotationSpeeds.Instant

the current rotation mode


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