Feel 5.9.1
The best way to improve your game's feel and make it extra juicy
Loading...
Searching...
No Matches
MoreMountains.Feedbacks.MMPositionShaker Class Reference

This shaker will let you move the position of a transform, either once or permanently, shaking its position for the specified duration and within the specified range. You can apply that shake along a direction, randomized or not, with optional noise and attenuation. More...

Inheritance diagram for MoreMountains.Feedbacks.MMPositionShaker:
MoreMountains.Feedbacks.MMShaker MoreMountains.Tools.MMMonoBehaviour

Public Types

enum  Modes { Transform , RectTransform }

Public Member Functions

virtual void GrabInitialPosition ()
virtual void OnMMPositionShakeEvent (float duration, float shakeSpeed, float shakeRange, Vector3 shakeMainDirection, bool randomizeDirection, Vector3 shakeAltDirection, bool randomizeDirectionOnPlay, bool randomizeDirectionX, bool randomizeDirectionY, bool randomizeDirectionZ, bool addDirectionalNoise, Vector3 directionalNoiseStrengthMin, Vector3 directionalNoiseStrengthMax, Vector3 randomnessSeed, bool randomizeSeedOnShake, bool useAttenuation, AnimationCurve attenuationCurve, bool useRange=false, float rangeDistance=0f, bool useRangeFalloff=false, AnimationCurve rangeFalloff=null, Vector2 remapRangeFalloff=default(Vector2), Vector3 rangePosition=default(Vector3), float feedbacksIntensity=1.0f, MMChannelData channelData=null, bool resetShakerValuesAfterShake=true, bool resetTargetValuesAfterShake=true, bool forwardDirection=true, TimescaleModes timescaleMode=TimescaleModes.Scaled, bool stop=false, bool restore=false)
override void StartListening ()
 Starts listening for events.
override void StopListening ()
 Stops listening for events.
Public Member Functions inherited from MoreMountains.Feedbacks.MMShaker
virtual float GetTime ()
virtual float GetDeltaTime ()
virtual void ForceInitialization ()
 Call this externally if you need to force a new initialization.
virtual void StartShaking ()
 Starts shaking the values.
virtual void Play ()
 Starts this shaker.
virtual void Stop ()
 Stops this shaker.
virtual float ComputeRangeIntensity (bool useRange, float rangeDistance, bool useRangeFalloff, AnimationCurve rangeFalloff, Vector2 remapRangeFalloff, Vector3 rangePosition)

Public Attributes

Modes Mode = Modes.Transform
 whether this shaker should target Transforms or RectTransforms
Transform TargetTransform
 the transform to shake the position of. If left blank, this component will target the transform it's put on.
RectTransform TargetRectTransform
 the rect transform to shake the position of. If left blank, this component will target the transform it's put on.
float ShakeSpeed = 20f
 the speed at which the transform should shake
float ShakeRange = 0.5f
 the maximum distance from its initial position the transform will move to during the shake
float OscillationOffset = 0f
 an offset to apply to the oscillation
Vector3 ShakeMainDirection = Vector3.up
 the direction along which to shake the transform's position
bool RandomizeDirection = false
 if this is true, instead of using ShakeMainDirection as the direction of the shake, a random vector3 will be generated, randomized between ShakeMainDirection and ShakeAltDirection
Vector3 ShakeAltDirection = Vector3.up
 when in RandomizeDirection mode, a vector against which to randomize the main direction
bool RandomizeDirectionOnPlay = false
 if this is true, a new direction will be randomized every time a shake happens
bool RandomizeDirectionX = true
 whether or not to randomize the x value of the main direction
bool RandomizeDirectionY = true
 whether or not to randomize the y value of the main direction
bool RandomizeDirectionZ = true
 whether or not to randomize the z value of the main direction
bool AddDirectionalNoise = true
 whether or not to add noise to the main direction
Vector3 DirectionalNoiseStrengthMin = new Vector3(0.25f, 0.25f, 0.25f)
 when adding directional noise, noise strength will be randomized between this value and DirectionalNoiseStrengthMax
Vector3 DirectionalNoiseStrengthMax = new Vector3(0.25f, 0.25f, 0.25f)
 when adding directional noise, noise strength will be randomized between this value and DirectionalNoiseStrengthMin
Vector3 RandomnessSeed
 a unique seed you can use to get different outcomes when shaking more than one transform at once
bool RandomizeSeedOnShake = true
 whether or not to generate a unique seed automatically on every shake
bool UseAttenuation = true
 whether or not to use attenuation, which will impact the amplitude of the shake, along the defined curve
AnimationCurve AttenuationCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0))
 the animation curve used to define attenuation, impacting the amplitude of the shake
bool StartShakingButton
Public Attributes inherited from MoreMountains.Feedbacks.MMShaker
MMChannelModes ChannelMode = MMChannelModes.Int
int Channel = 0
 the channel to listen to - has to match the one on the feedback
MMChannel MMChannelDefinition = null
float ShakeDuration = 0.2f
 the duration of the shake, in seconds
bool PlayOnAwake = false
 if this is true this shaker will play on awake
bool PermanentShake = false
 if this is true, the shaker will shake permanently as long as its game object is active
bool Interruptible = true
 if this is true, a new shake can happen while shaking
bool AlwaysResetTargetValuesAfterShake = false
 if this is true, this shaker will always reset target values, regardless of how it was called
bool OnlyUseShakerValues = false
 if this is true, this shaker will ignore any value passed in an event that triggered it, and will instead use the values set on its inspector
float CooldownBetweenShakes = 0f
 a cooldown, in seconds, after a shake, during which no other shake can start
bool Shaking = false
 whether or not this shaker is shaking right now
bool ForwardDirection = true
TimescaleModes TimescaleMode = TimescaleModes.Scaled

Protected Member Functions

override void Initialization ()
 On init we initialize our values.
virtual void Reset ()
 When that shaker gets added, we initialize its shake duration.
override void ShakeStarts ()
 Describes what happens when a shake starts.
override void Shake ()
 Override this method to implement shake over time.
override void ShakeComplete ()
 Describes what happens when the shake is complete.
virtual void ApplyNewPosition (Vector3 newPosition)
virtual Vector3 ComputeNewPosition ()
virtual float ComputeAttenuation (float remappedTime)
virtual Vector3 ComputeNoise (float time)
override void ResetTargetValues ()
 Resets the target's values.
override void ResetShakerValues ()
 Resets the shaker's values.
Protected Member Functions inherited from MoreMountains.Feedbacks.MMShaker
virtual void Awake ()
 On Awake we grab our volume and profile.
virtual void SetShakeStartedTimestamp ()
 Logs the start timestamp for this shaker.
virtual void GrabInitialValues ()
 A method designed to collect initial values.
virtual void Update ()
 On Update, we shake our values if needed, or reset if our shake has ended.
virtual float ShakeFloat (AnimationCurve curve, float remapMin, float remapMax, bool relativeIntensity, float initialValue)
 A method used to "shake" a flot over time along a curve.
virtual Color ShakeGradient (Gradient gradient)
virtual void OnEnable ()
 On enable we start shaking if needed.
virtual void OnDestroy ()
 On destroy we stop listening for events.
virtual void OnDisable ()
 On disable we complete our shake if it was in progress.
virtual bool CheckEventAllowed (MMChannelData channelData, bool useRange=false, float range=0f, Vector3 eventOriginPosition=default(Vector3))
 Returns true if this shaker should listen to events, false otherwise.

Protected Attributes

float _attenuation = 1f
float _oscillation
Vector3 _initialPosition
Vector3 _workDirection
Vector3 _noiseVector
Vector3 _newPosition
Vector3 _randomNoiseStrength
Vector3 _noNoise = Vector3.zero
Vector3 _randomizedDirection
float _originalDuration
float _originalShakeSpeed
float _originalShakeRange
Vector3 _originalShakeMainDirection
bool _originalRandomizeDirection
Vector3 _originalShakeAltDirection
bool _originalRandomizeDirectionOnPlay
bool _originalRandomizeDirectionX
bool _originalRandomizeDirectionY
bool _originalRandomizeDirectionZ
bool _originalAddDirectionalNoise
Vector3 _originalDirectionalNoiseStrengthMin
Vector3 _originalDirectionalNoiseStrengthMax
Vector3 _originalRandomnessSeed
bool _originalRandomizeSeedOnShake
bool _originalUseAttenuation
AnimationCurve _originalAttenuationCurve
Protected Attributes inherited from MoreMountains.Feedbacks.MMShaker
float _shakeStartedTimestamp = -Single.MaxValue
float _shakeStartedTimestampUnscaled = -Single.MaxValue
float _remappedTimeSinceStart
bool _resetShakerValuesAfterShake
bool _resetTargetValuesAfterShake
float _journey

Properties

virtual float Randomness [get]
Properties inherited from MoreMountains.Feedbacks.MMShaker
virtual MMChannelData ChannelData [get]
virtual bool ListeningToEvents [get]
virtual bool InCooldown [get]
 Returns true if this shaker is currently in cooldown, false otherwise.

Detailed Description

This shaker will let you move the position of a transform, either once or permanently, shaking its position for the specified duration and within the specified range. You can apply that shake along a direction, randomized or not, with optional noise and attenuation.

Member Enumeration Documentation

◆ Modes

Enumerator
Transform 
RectTransform 

Member Function Documentation

◆ ApplyNewPosition()

virtual void MoreMountains.Feedbacks.MMPositionShaker.ApplyNewPosition ( Vector3 newPosition)
protectedvirtual

◆ ComputeAttenuation()

virtual float MoreMountains.Feedbacks.MMPositionShaker.ComputeAttenuation ( float remappedTime)
protectedvirtual

◆ ComputeNewPosition()

virtual Vector3 MoreMountains.Feedbacks.MMPositionShaker.ComputeNewPosition ( )
protectedvirtual

◆ ComputeNoise()

virtual Vector3 MoreMountains.Feedbacks.MMPositionShaker.ComputeNoise ( float time)
protectedvirtual

◆ GrabInitialPosition()

virtual void MoreMountains.Feedbacks.MMPositionShaker.GrabInitialPosition ( )
virtual

◆ Initialization()

override void MoreMountains.Feedbacks.MMPositionShaker.Initialization ( )
protectedvirtual

On init we initialize our values.

Reimplemented from MoreMountains.Feedbacks.MMShaker.

◆ OnMMPositionShakeEvent()

virtual void MoreMountains.Feedbacks.MMPositionShaker.OnMMPositionShakeEvent ( float duration,
float shakeSpeed,
float shakeRange,
Vector3 shakeMainDirection,
bool randomizeDirection,
Vector3 shakeAltDirection,
bool randomizeDirectionOnPlay,
bool randomizeDirectionX,
bool randomizeDirectionY,
bool randomizeDirectionZ,
bool addDirectionalNoise,
Vector3 directionalNoiseStrengthMin,
Vector3 directionalNoiseStrengthMax,
Vector3 randomnessSeed,
bool randomizeSeedOnShake,
bool useAttenuation,
AnimationCurve attenuationCurve,
bool useRange = false,
float rangeDistance = 0f,
bool useRangeFalloff = false,
AnimationCurve rangeFalloff = null,
Vector2 remapRangeFalloff = default(Vector2),
Vector3 rangePosition = default(Vector3),
float feedbacksIntensity = 1::0f,
MMChannelData channelData = null,
bool resetShakerValuesAfterShake = true,
bool resetTargetValuesAfterShake = true,
bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes::Scaled,
bool stop = false,
bool restore = false )
virtual

◆ Reset()

virtual void MoreMountains.Feedbacks.MMPositionShaker.Reset ( )
protectedvirtual

When that shaker gets added, we initialize its shake duration.

◆ ResetShakerValues()

override void MoreMountains.Feedbacks.MMPositionShaker.ResetShakerValues ( )
protectedvirtual

Resets the shaker's values.

Reimplemented from MoreMountains.Feedbacks.MMShaker.

◆ ResetTargetValues()

override void MoreMountains.Feedbacks.MMPositionShaker.ResetTargetValues ( )
protectedvirtual

Resets the target's values.

Reimplemented from MoreMountains.Feedbacks.MMShaker.

◆ Shake()

override void MoreMountains.Feedbacks.MMPositionShaker.Shake ( )
protectedvirtual

Override this method to implement shake over time.

Reimplemented from MoreMountains.Feedbacks.MMShaker.

◆ ShakeComplete()

override void MoreMountains.Feedbacks.MMPositionShaker.ShakeComplete ( )
protectedvirtual

Describes what happens when the shake is complete.

Reimplemented from MoreMountains.Feedbacks.MMShaker.

◆ ShakeStarts()

override void MoreMountains.Feedbacks.MMPositionShaker.ShakeStarts ( )
protectedvirtual

Describes what happens when a shake starts.

Reimplemented from MoreMountains.Feedbacks.MMShaker.

◆ StartListening()

override void MoreMountains.Feedbacks.MMPositionShaker.StartListening ( )
virtual

Starts listening for events.

Reimplemented from MoreMountains.Feedbacks.MMShaker.

◆ StopListening()

override void MoreMountains.Feedbacks.MMPositionShaker.StopListening ( )
virtual

Stops listening for events.

Reimplemented from MoreMountains.Feedbacks.MMShaker.

Member Data Documentation

◆ _attenuation

float MoreMountains.Feedbacks.MMPositionShaker._attenuation = 1f
protected

◆ _initialPosition

Vector3 MoreMountains.Feedbacks.MMPositionShaker._initialPosition
protected

◆ _newPosition

Vector3 MoreMountains.Feedbacks.MMPositionShaker._newPosition
protected

◆ _noiseVector

Vector3 MoreMountains.Feedbacks.MMPositionShaker._noiseVector
protected

◆ _noNoise

Vector3 MoreMountains.Feedbacks.MMPositionShaker._noNoise = Vector3.zero
protected

◆ _originalAddDirectionalNoise

bool MoreMountains.Feedbacks.MMPositionShaker._originalAddDirectionalNoise
protected

◆ _originalAttenuationCurve

AnimationCurve MoreMountains.Feedbacks.MMPositionShaker._originalAttenuationCurve
protected

◆ _originalDirectionalNoiseStrengthMax

Vector3 MoreMountains.Feedbacks.MMPositionShaker._originalDirectionalNoiseStrengthMax
protected

◆ _originalDirectionalNoiseStrengthMin

Vector3 MoreMountains.Feedbacks.MMPositionShaker._originalDirectionalNoiseStrengthMin
protected

◆ _originalDuration

float MoreMountains.Feedbacks.MMPositionShaker._originalDuration
protected

◆ _originalRandomizeDirection

bool MoreMountains.Feedbacks.MMPositionShaker._originalRandomizeDirection
protected

◆ _originalRandomizeDirectionOnPlay

bool MoreMountains.Feedbacks.MMPositionShaker._originalRandomizeDirectionOnPlay
protected

◆ _originalRandomizeDirectionX

bool MoreMountains.Feedbacks.MMPositionShaker._originalRandomizeDirectionX
protected

◆ _originalRandomizeDirectionY

bool MoreMountains.Feedbacks.MMPositionShaker._originalRandomizeDirectionY
protected

◆ _originalRandomizeDirectionZ

bool MoreMountains.Feedbacks.MMPositionShaker._originalRandomizeDirectionZ
protected

◆ _originalRandomizeSeedOnShake

bool MoreMountains.Feedbacks.MMPositionShaker._originalRandomizeSeedOnShake
protected

◆ _originalRandomnessSeed

Vector3 MoreMountains.Feedbacks.MMPositionShaker._originalRandomnessSeed
protected

◆ _originalShakeAltDirection

Vector3 MoreMountains.Feedbacks.MMPositionShaker._originalShakeAltDirection
protected

◆ _originalShakeMainDirection

Vector3 MoreMountains.Feedbacks.MMPositionShaker._originalShakeMainDirection
protected

◆ _originalShakeRange

float MoreMountains.Feedbacks.MMPositionShaker._originalShakeRange
protected

◆ _originalShakeSpeed

float MoreMountains.Feedbacks.MMPositionShaker._originalShakeSpeed
protected

◆ _originalUseAttenuation

bool MoreMountains.Feedbacks.MMPositionShaker._originalUseAttenuation
protected

◆ _oscillation

float MoreMountains.Feedbacks.MMPositionShaker._oscillation
protected

◆ _randomizedDirection

Vector3 MoreMountains.Feedbacks.MMPositionShaker._randomizedDirection
protected

◆ _randomNoiseStrength

Vector3 MoreMountains.Feedbacks.MMPositionShaker._randomNoiseStrength
protected

◆ _workDirection

Vector3 MoreMountains.Feedbacks.MMPositionShaker._workDirection
protected

◆ AddDirectionalNoise

bool MoreMountains.Feedbacks.MMPositionShaker.AddDirectionalNoise = true

whether or not to add noise to the main direction

◆ AttenuationCurve

AnimationCurve MoreMountains.Feedbacks.MMPositionShaker.AttenuationCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0))

the animation curve used to define attenuation, impacting the amplitude of the shake

◆ DirectionalNoiseStrengthMax

Vector3 MoreMountains.Feedbacks.MMPositionShaker.DirectionalNoiseStrengthMax = new Vector3(0.25f, 0.25f, 0.25f)

when adding directional noise, noise strength will be randomized between this value and DirectionalNoiseStrengthMin

◆ DirectionalNoiseStrengthMin

Vector3 MoreMountains.Feedbacks.MMPositionShaker.DirectionalNoiseStrengthMin = new Vector3(0.25f, 0.25f, 0.25f)

when adding directional noise, noise strength will be randomized between this value and DirectionalNoiseStrengthMax

◆ Mode

Modes MoreMountains.Feedbacks.MMPositionShaker.Mode = Modes.Transform

whether this shaker should target Transforms or RectTransforms

◆ OscillationOffset

float MoreMountains.Feedbacks.MMPositionShaker.OscillationOffset = 0f

an offset to apply to the oscillation

◆ RandomizeDirection

bool MoreMountains.Feedbacks.MMPositionShaker.RandomizeDirection = false

if this is true, instead of using ShakeMainDirection as the direction of the shake, a random vector3 will be generated, randomized between ShakeMainDirection and ShakeAltDirection

◆ RandomizeDirectionOnPlay

bool MoreMountains.Feedbacks.MMPositionShaker.RandomizeDirectionOnPlay = false

if this is true, a new direction will be randomized every time a shake happens

◆ RandomizeDirectionX

bool MoreMountains.Feedbacks.MMPositionShaker.RandomizeDirectionX = true

whether or not to randomize the x value of the main direction

◆ RandomizeDirectionY

bool MoreMountains.Feedbacks.MMPositionShaker.RandomizeDirectionY = true

whether or not to randomize the y value of the main direction

◆ RandomizeDirectionZ

bool MoreMountains.Feedbacks.MMPositionShaker.RandomizeDirectionZ = true

whether or not to randomize the z value of the main direction

◆ RandomizeSeedOnShake

bool MoreMountains.Feedbacks.MMPositionShaker.RandomizeSeedOnShake = true

whether or not to generate a unique seed automatically on every shake

◆ RandomnessSeed

Vector3 MoreMountains.Feedbacks.MMPositionShaker.RandomnessSeed

a unique seed you can use to get different outcomes when shaking more than one transform at once

◆ ShakeAltDirection

Vector3 MoreMountains.Feedbacks.MMPositionShaker.ShakeAltDirection = Vector3.up

when in RandomizeDirection mode, a vector against which to randomize the main direction

◆ ShakeMainDirection

Vector3 MoreMountains.Feedbacks.MMPositionShaker.ShakeMainDirection = Vector3.up

the direction along which to shake the transform's position

◆ ShakeRange

float MoreMountains.Feedbacks.MMPositionShaker.ShakeRange = 0.5f

the maximum distance from its initial position the transform will move to during the shake

◆ ShakeSpeed

float MoreMountains.Feedbacks.MMPositionShaker.ShakeSpeed = 20f

the speed at which the transform should shake

◆ StartShakingButton

bool MoreMountains.Feedbacks.MMPositionShaker.StartShakingButton

◆ TargetRectTransform

RectTransform MoreMountains.Feedbacks.MMPositionShaker.TargetRectTransform

the rect transform to shake the position of. If left blank, this component will target the transform it's put on.

◆ TargetTransform

Transform MoreMountains.Feedbacks.MMPositionShaker.TargetTransform

the transform to shake the position of. If left blank, this component will target the transform it's put on.

◆ UseAttenuation

bool MoreMountains.Feedbacks.MMPositionShaker.UseAttenuation = true

whether or not to use attenuation, which will impact the amplitude of the shake, along the defined curve

Property Documentation

◆ Randomness

virtual float MoreMountains.Feedbacks.MMPositionShaker.Randomness
get

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