TopDown Engine v5.1
Loading...
Searching...
No Matches
MoreMountains.Feedbacks.MMF_Gravity Class Reference

This feedback lets you change the global gravity (Physics.gravity and/or Physics2D.gravity), either once, instantly then reset after a duration, or over time along a curve. More...

Inheritance diagram for MoreMountains.Feedbacks.MMF_Gravity:
MoreMountains.Feedbacks.MMF_Feedback

Public Types

enum  Modes { Instant , InstantThenReset , OverTime }
enum  Dimensions { Physics3D , Physics2D , Both }
 the physics engines whose gravity this feedback should change More...
enum  ValueModes { Multiplier , Absolute }

Public Attributes

Dimensions Dimension = Dimensions.Physics3D
 the physics engines whose gravity this feedback should change (2D requires the Physics 2D module)
Modes Mode = Modes.InstantThenReset
 whether to change the gravity once, instantly then reset it after a duration, or over time along a curve
ValueModes ValueMode = ValueModes.Multiplier
 whether to multiply the gravity found on play, or move it towards an absolute value
float Duration = 1f
 in InstantThenReset and OverTime modes, how long the gravity change should last, in seconds
bool AllowAdditivePlays = false
 if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over
bool ResetOnStop = true
 if this is true, the gravity will be reset to the value it had before this feedback played when the feedback gets stopped
float Multiplier = 0.25f
 in Instant and InstantThenReset modes, when in Multiplier value mode, the value to multiply the gravity by (0.25 is low gravity, 2 is heavy gravity, -1 flips it)
Vector3 TargetGravity = new Vector3(0f, -2.5f, 0f)
 in Absolute value mode, the gravity to apply to 3D physics
Vector2 TargetGravity2D = new Vector2(0f, -2.5f)
 in Absolute value mode, the gravity to apply to 2D physics
MMTweenType Curve
 in OverTime mode, the curve along which to evaluate the gravity. Its value gets remapped between CurveRemapZero and CurveRemapOne
float CurveRemapZero = 1f
 in OverTime mode, the value to remap the curve's zero to. In Multiplier value mode, it's the gravity multiplier. In Absolute value mode, 0 is the initial gravity and 1 is the target gravity
float CurveRemapOne = 0.25f
 in OverTime mode, the value to remap the curve's one to. In Multiplier value mode, it's the gravity multiplier. In Absolute value mode, 0 is the initial gravity and 1 is the target gravity

Static Public Attributes

static bool FeedbackTypeAuthorized = true
 a static bool used to disable all feedbacks of this type at once

Protected Member Functions

override void CustomPlayFeedback (Vector3 position, float feedbacksIntensity=1.0f)
 On play, stores the current gravity and changes it according to the selected mode.
virtual IEnumerator GravitySequence ()
 A coroutine used to change the gravity in InstantThenReset and OverTime modes.
virtual void ApplyInstantValue ()
 Applies the gravity defined for Instant and InstantThenReset modes.
virtual void ApplyCurveValue (float normalizedTime)
 Evaluates the curve at the specified normalized time and applies the resulting gravity.
virtual void ApplyValue (float value)
 Computes the gravity for the specified value (a multiplier, or a lerp factor between initial and target gravity in Absolute mode), scales its deviation from the initial gravity by the feedback's intensity, and applies it.
virtual void ApplyGravity (Vector3 gravity, Vector2 gravity2D)
 Sets the gravity on the selected physics engines.
virtual void StoreInitialGravity ()
 Stores the gravity before this feedback changes it.
virtual void StoreProjectGravity ()
 In the editor, stores the project's gravity the first time any gravity feedback plays, so it can be restored when exiting Play mode (gravity is a project setting, and changes made to it in Play mode would otherwise stick)
override void CustomStopFeedback (Vector3 position, float feedbacksIntensity=1)
 On stop, stops the coroutine and resets the gravity if needed.
override void CustomRestoreInitialValues ()
 On restore, puts the gravity back to the value it had before this feedback played.

Protected Attributes

Coroutine _coroutine
Vector3 _initialGravity
Vector2 _initialGravity2D
float _intensityMultiplier = 1f
bool _initialGravityStored = false

Properties

override bool HasRandomness [get]
 sets the inspector color for this feedback
override float FeedbackDuration [get, set]
 the duration of this feedback is the duration of the gravity change, or 0 if instant

Additional Inherited Members

Detailed Description

This feedback lets you change the global gravity (Physics.gravity and/or Physics2D.gravity), either once, instantly then reset after a duration, or over time along a curve.

Member Enumeration Documentation

◆ Dimensions

the physics engines whose gravity this feedback should change

Enumerator
Physics3D 
Physics2D 
Both 

◆ Modes

the possible modes for this feedback

  • Instant : the gravity is changed once, and stays that way
  • InstantThenReset : the gravity is changed, then reset to its previous value after Duration
  • OverTime : the gravity is evaluated along a curve over Duration
Enumerator
Instant 
InstantThenReset 
OverTime 

◆ ValueModes

how the new gravity is computed

  • Multiplier : the gravity found on play gets multiplied by a value
  • Absolute : the gravity moves towards a target vector
Enumerator
Multiplier 
Absolute 

Member Function Documentation

◆ ApplyCurveValue()

virtual void MoreMountains.Feedbacks.MMF_Gravity.ApplyCurveValue ( float normalizedTime)
protectedvirtual

Evaluates the curve at the specified normalized time and applies the resulting gravity.

Parameters
normalizedTime

◆ ApplyGravity()

virtual void MoreMountains.Feedbacks.MMF_Gravity.ApplyGravity ( Vector3 gravity,
Vector2 gravity2D )
protectedvirtual

Sets the gravity on the selected physics engines.

Parameters
gravity
gravity2D

◆ ApplyInstantValue()

virtual void MoreMountains.Feedbacks.MMF_Gravity.ApplyInstantValue ( )
protectedvirtual

Applies the gravity defined for Instant and InstantThenReset modes.

◆ ApplyValue()

virtual void MoreMountains.Feedbacks.MMF_Gravity.ApplyValue ( float value)
protectedvirtual

Computes the gravity for the specified value (a multiplier, or a lerp factor between initial and target gravity in Absolute mode), scales its deviation from the initial gravity by the feedback's intensity, and applies it.

Parameters
value

◆ CustomPlayFeedback()

override void MoreMountains.Feedbacks.MMF_Gravity.CustomPlayFeedback ( Vector3 position,
float feedbacksIntensity = 1::0f )
protected

On play, stores the current gravity and changes it according to the selected mode.

Parameters
position
feedbacksIntensity

◆ CustomRestoreInitialValues()

override void MoreMountains.Feedbacks.MMF_Gravity.CustomRestoreInitialValues ( )
protectedvirtual

On restore, puts the gravity back to the value it had before this feedback played.

Reimplemented from MoreMountains.Feedbacks.MMF_Feedback.

◆ CustomStopFeedback()

override void MoreMountains.Feedbacks.MMF_Gravity.CustomStopFeedback ( Vector3 position,
float feedbacksIntensity = 1 )
protectedvirtual

On stop, stops the coroutine and resets the gravity if needed.

Parameters
position
feedbacksIntensity

Reimplemented from MoreMountains.Feedbacks.MMF_Feedback.

◆ GravitySequence()

virtual IEnumerator MoreMountains.Feedbacks.MMF_Gravity.GravitySequence ( )
protectedvirtual

A coroutine used to change the gravity in InstantThenReset and OverTime modes.

Returns

◆ StoreInitialGravity()

virtual void MoreMountains.Feedbacks.MMF_Gravity.StoreInitialGravity ( )
protectedvirtual

Stores the gravity before this feedback changes it.

◆ StoreProjectGravity()

virtual void MoreMountains.Feedbacks.MMF_Gravity.StoreProjectGravity ( )
protectedvirtual

In the editor, stores the project's gravity the first time any gravity feedback plays, so it can be restored when exiting Play mode (gravity is a project setting, and changes made to it in Play mode would otherwise stick)

Member Data Documentation

◆ _coroutine

Coroutine MoreMountains.Feedbacks.MMF_Gravity._coroutine
protected

◆ _initialGravity

Vector3 MoreMountains.Feedbacks.MMF_Gravity._initialGravity
protected

◆ _initialGravity2D

Vector2 MoreMountains.Feedbacks.MMF_Gravity._initialGravity2D
protected

◆ _initialGravityStored

bool MoreMountains.Feedbacks.MMF_Gravity._initialGravityStored = false
protected

◆ _intensityMultiplier

float MoreMountains.Feedbacks.MMF_Gravity._intensityMultiplier = 1f
protected

◆ AllowAdditivePlays

bool MoreMountains.Feedbacks.MMF_Gravity.AllowAdditivePlays = false

if this is true, calling that feedback will trigger it, even if it's in progress. If it's false, it'll prevent any new Play until the current one is over

◆ Curve

MMTweenType MoreMountains.Feedbacks.MMF_Gravity.Curve
Initial value:
= new MMTweenType(new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0)),
enumConditionPropertyName:"Mode", enumConditionValues:(int)Modes.OverTime)
Modes
Definition MMF_Gravity.cs:37

in OverTime mode, the curve along which to evaluate the gravity. Its value gets remapped between CurveRemapZero and CurveRemapOne

◆ CurveRemapOne

float MoreMountains.Feedbacks.MMF_Gravity.CurveRemapOne = 0.25f

in OverTime mode, the value to remap the curve's one to. In Multiplier value mode, it's the gravity multiplier. In Absolute value mode, 0 is the initial gravity and 1 is the target gravity

◆ CurveRemapZero

float MoreMountains.Feedbacks.MMF_Gravity.CurveRemapZero = 1f

in OverTime mode, the value to remap the curve's zero to. In Multiplier value mode, it's the gravity multiplier. In Absolute value mode, 0 is the initial gravity and 1 is the target gravity

◆ Dimension

Dimensions MoreMountains.Feedbacks.MMF_Gravity.Dimension = Dimensions.Physics3D

the physics engines whose gravity this feedback should change (2D requires the Physics 2D module)

◆ Duration

float MoreMountains.Feedbacks.MMF_Gravity.Duration = 1f

in InstantThenReset and OverTime modes, how long the gravity change should last, in seconds

◆ FeedbackTypeAuthorized

bool MoreMountains.Feedbacks.MMF_Gravity.FeedbackTypeAuthorized = true
static

a static bool used to disable all feedbacks of this type at once

◆ Mode

Modes MoreMountains.Feedbacks.MMF_Gravity.Mode = Modes.InstantThenReset

whether to change the gravity once, instantly then reset it after a duration, or over time along a curve

◆ Multiplier

float MoreMountains.Feedbacks.MMF_Gravity.Multiplier = 0.25f

in Instant and InstantThenReset modes, when in Multiplier value mode, the value to multiply the gravity by (0.25 is low gravity, 2 is heavy gravity, -1 flips it)

◆ ResetOnStop

bool MoreMountains.Feedbacks.MMF_Gravity.ResetOnStop = true

if this is true, the gravity will be reset to the value it had before this feedback played when the feedback gets stopped

◆ TargetGravity

Vector3 MoreMountains.Feedbacks.MMF_Gravity.TargetGravity = new Vector3(0f, -2.5f, 0f)

in Absolute value mode, the gravity to apply to 3D physics

◆ TargetGravity2D

Vector2 MoreMountains.Feedbacks.MMF_Gravity.TargetGravity2D = new Vector2(0f, -2.5f)

in Absolute value mode, the gravity to apply to 2D physics

◆ ValueMode

ValueModes MoreMountains.Feedbacks.MMF_Gravity.ValueMode = ValueModes.Multiplier

whether to multiply the gravity found on play, or move it towards an absolute value

Property Documentation

◆ FeedbackDuration

override float MoreMountains.Feedbacks.MMF_Gravity.FeedbackDuration
getset

the duration of this feedback is the duration of the gravity change, or 0 if instant

◆ HasRandomness

override bool MoreMountains.Feedbacks.MMF_Gravity.HasRandomness
get

sets the inspector color for this feedback


The documentation for this class was generated from the following file:
  • H:/Code/MoreMountains/topdownengine/Assets/TopDownEngine/ThirdParty/MoreMountains/MMFeedbacks/MMFeedbacks/Feedbacks/MMF_Gravity.cs