Highroad Engine v1.3
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
MoreMountains.Tools.MMSquashAndStretch Class Reference

This component will automatically update scale and rotation Put it one level below the top, and have the model one level below that Hierarchy should be as follows : More...

Inheritance diagram for MoreMountains.Tools.MMSquashAndStretch:

Public Types

enum  Timescales { Regular , Unscaled }
 
enum  Modes { Rigidbody , Rigidbody2D , Position }
 

Public Member Functions

virtual void Squash (float duration, float intensity)
 Triggered either directly or via the AutoSquash setting, this squashes the object (usually after a contact / stop) More...
 

Public Attributes

Modes Mode = Modes.Position
 the possible ways to get velocity from More...
 
Timescales Timescale = Timescales.Regular
 whether we should use deltaTime or unscaledDeltaTime; More...
 
float Intensity = 0.02f
 the intensity of the squash and stretch More...
 
float MaximumVelocity = 1f
 the maximum velocity of your parent object, used to remap the computed one More...
 
Vector2 MinimumScale = new Vector2(0.5f, 0.5f)
 the minimum scale to apply to this object More...
 
Vector2 MaximumScale = new Vector2(2f, 2f)
 the maximum scale to apply to this object More...
 
bool AutoSquashOnStop = false
 if this is true, the object will squash once velocity goes below the specified threshold More...
 
AnimationCurve SquashCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1f), new Keyframe(1, 0f))
 the curve to apply when squashing the object (this describes scale on x and z, will be inverted for y to maintain mass) More...
 
float SquashVelocityThreshold = 0.1f
 the velocity threshold after which a squash can be triggered if the object stops More...
 
Vector2 SquashDuration = new Vector2(0.25f, 0.5f)
 the maximum duration of the squash (will be reduced if velocity is low) More...
 
Vector2 SquashIntensity = new Vector2(0f, 1f)
 the maximum intensity of the squash More...
 
bool Spring = false
 whether or not to add extra spring to the squash and stretch More...
 
float SpringDamping = 0.3f
 the damping to apply to the spring More...
 
float SpringFrequency = 3f
 the spring's frequency More...
 
float SpringSpeed = 10f
 the speed of the spring More...
 
Vector3 Velocity
 the current velocity of the parent object More...
 
float RemappedVelocity
 the remapped velocity More...
 
float VelocityMagnitude
 the current velocity magnitude More...
 

Protected Member Functions

virtual void Start ()
 On start, we initialize our component More...
 
virtual void Initialization ()
 Stores the initial scale, grabs the rigidbodies (or tries to), as well as the parent and child More...
 
virtual void LateUpdate ()
 On late update, we apply our squash and stretch effect More...
 
virtual void SquashAndStretch ()
 Computes velocity and applies the effect More...
 
virtual void ComputeVelocityAndDirection ()
 Determines the current velocity and direction of the parent object More...
 
virtual void ComputeNewRotation ()
 Computes a new rotation for both this object and the child More...
 
virtual void ComputeNewLocalScale ()
 Computes a new local scale for this object More...
 
virtual void StorePreviousPosition ()
 Stores the previous position of the parent to compute velocity More...
 

Protected Attributes

Rigidbody2D _rigidbody2D
 
Rigidbody _rigidbody
 
Transform _childTransform
 
Transform _parentTransform
 
Vector3 _direction
 
Vector3 _previousPosition
 
Vector3 _newLocalScale
 
Vector3 _initialScale
 
Quaternion _newRotation = Quaternion.identity
 
Quaternion _deltaRotation
 
float _squashStartedAt = 0f
 
bool _squashing = false
 
float _squashIntensity
 
float _squashDuration
 
bool _movementStarted = false
 
float _lastVelocity = 0f
 
Vector3 _springScale
 
Vector3 _springVelocity = Vector3.zero
 

Properties

float? TimescaleTime [get]
 
float? TimescaleDeltaTime [get]
 

Detailed Description

This component will automatically update scale and rotation Put it one level below the top, and have the model one level below that Hierarchy should be as follows :

Parent (where the logic (and optionnally rigidbody lies)

Make sure this intermediary layer only has one child If movement feels glitchy make sure your rigidbody is on Interpolate

Member Enumeration Documentation

◆ Modes

Enumerator
Rigidbody 
Rigidbody2D 
Position 

◆ Timescales

Enumerator
Regular 
Unscaled 

Member Function Documentation

◆ ComputeNewLocalScale()

virtual void MoreMountains.Tools.MMSquashAndStretch.ComputeNewLocalScale ( )
protectedvirtual

Computes a new local scale for this object

◆ ComputeNewRotation()

virtual void MoreMountains.Tools.MMSquashAndStretch.ComputeNewRotation ( )
protectedvirtual

Computes a new rotation for both this object and the child

◆ ComputeVelocityAndDirection()

virtual void MoreMountains.Tools.MMSquashAndStretch.ComputeVelocityAndDirection ( )
protectedvirtual

Determines the current velocity and direction of the parent object

◆ Initialization()

virtual void MoreMountains.Tools.MMSquashAndStretch.Initialization ( )
protectedvirtual

Stores the initial scale, grabs the rigidbodies (or tries to), as well as the parent and child

◆ LateUpdate()

virtual void MoreMountains.Tools.MMSquashAndStretch.LateUpdate ( )
protectedvirtual

On late update, we apply our squash and stretch effect

◆ Squash()

virtual void MoreMountains.Tools.MMSquashAndStretch.Squash ( float  duration,
float  intensity 
)
virtual

Triggered either directly or via the AutoSquash setting, this squashes the object (usually after a contact / stop)

Parameters
duration
intensity

◆ SquashAndStretch()

virtual void MoreMountains.Tools.MMSquashAndStretch.SquashAndStretch ( )
protectedvirtual

Computes velocity and applies the effect

◆ Start()

virtual void MoreMountains.Tools.MMSquashAndStretch.Start ( )
protectedvirtual

On start, we initialize our component

◆ StorePreviousPosition()

virtual void MoreMountains.Tools.MMSquashAndStretch.StorePreviousPosition ( )
protectedvirtual

Stores the previous position of the parent to compute velocity

Member Data Documentation

◆ _childTransform

Transform MoreMountains.Tools.MMSquashAndStretch._childTransform
protected

◆ _deltaRotation

Quaternion MoreMountains.Tools.MMSquashAndStretch._deltaRotation
protected

◆ _direction

Vector3 MoreMountains.Tools.MMSquashAndStretch._direction
protected

◆ _initialScale

Vector3 MoreMountains.Tools.MMSquashAndStretch._initialScale
protected

◆ _lastVelocity

float MoreMountains.Tools.MMSquashAndStretch._lastVelocity = 0f
protected

◆ _movementStarted

bool MoreMountains.Tools.MMSquashAndStretch._movementStarted = false
protected

◆ _newLocalScale

Vector3 MoreMountains.Tools.MMSquashAndStretch._newLocalScale
protected

◆ _newRotation

Quaternion MoreMountains.Tools.MMSquashAndStretch._newRotation = Quaternion.identity
protected

◆ _parentTransform

Transform MoreMountains.Tools.MMSquashAndStretch._parentTransform
protected

◆ _previousPosition

Vector3 MoreMountains.Tools.MMSquashAndStretch._previousPosition
protected

◆ _rigidbody

Rigidbody MoreMountains.Tools.MMSquashAndStretch._rigidbody
protected

◆ _rigidbody2D

Rigidbody2D MoreMountains.Tools.MMSquashAndStretch._rigidbody2D
protected

◆ _springScale

Vector3 MoreMountains.Tools.MMSquashAndStretch._springScale
protected

◆ _springVelocity

Vector3 MoreMountains.Tools.MMSquashAndStretch._springVelocity = Vector3.zero
protected

◆ _squashDuration

float MoreMountains.Tools.MMSquashAndStretch._squashDuration
protected

◆ _squashing

bool MoreMountains.Tools.MMSquashAndStretch._squashing = false
protected

◆ _squashIntensity

float MoreMountains.Tools.MMSquashAndStretch._squashIntensity
protected

◆ _squashStartedAt

float MoreMountains.Tools.MMSquashAndStretch._squashStartedAt = 0f
protected

◆ AutoSquashOnStop

bool MoreMountains.Tools.MMSquashAndStretch.AutoSquashOnStop = false

if this is true, the object will squash once velocity goes below the specified threshold

◆ Intensity

float MoreMountains.Tools.MMSquashAndStretch.Intensity = 0.02f

the intensity of the squash and stretch

◆ MaximumScale

Vector2 MoreMountains.Tools.MMSquashAndStretch.MaximumScale = new Vector2(2f, 2f)

the maximum scale to apply to this object

◆ MaximumVelocity

float MoreMountains.Tools.MMSquashAndStretch.MaximumVelocity = 1f

the maximum velocity of your parent object, used to remap the computed one

◆ MinimumScale

Vector2 MoreMountains.Tools.MMSquashAndStretch.MinimumScale = new Vector2(0.5f, 0.5f)

the minimum scale to apply to this object

◆ Mode

Modes MoreMountains.Tools.MMSquashAndStretch.Mode = Modes.Position

the possible ways to get velocity from

◆ RemappedVelocity

float MoreMountains.Tools.MMSquashAndStretch.RemappedVelocity

the remapped velocity

◆ Spring

bool MoreMountains.Tools.MMSquashAndStretch.Spring = false

whether or not to add extra spring to the squash and stretch

◆ SpringDamping

float MoreMountains.Tools.MMSquashAndStretch.SpringDamping = 0.3f

the damping to apply to the spring

◆ SpringFrequency

float MoreMountains.Tools.MMSquashAndStretch.SpringFrequency = 3f

the spring's frequency

◆ SpringSpeed

float MoreMountains.Tools.MMSquashAndStretch.SpringSpeed = 10f

the speed of the spring

◆ SquashCurve

AnimationCurve MoreMountains.Tools.MMSquashAndStretch.SquashCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1f), new Keyframe(1, 0f))

the curve to apply when squashing the object (this describes scale on x and z, will be inverted for y to maintain mass)

◆ SquashDuration

Vector2 MoreMountains.Tools.MMSquashAndStretch.SquashDuration = new Vector2(0.25f, 0.5f)

the maximum duration of the squash (will be reduced if velocity is low)

◆ SquashIntensity

Vector2 MoreMountains.Tools.MMSquashAndStretch.SquashIntensity = new Vector2(0f, 1f)

the maximum intensity of the squash

◆ SquashVelocityThreshold

float MoreMountains.Tools.MMSquashAndStretch.SquashVelocityThreshold = 0.1f

the velocity threshold after which a squash can be triggered if the object stops

◆ Timescale

Timescales MoreMountains.Tools.MMSquashAndStretch.Timescale = Timescales.Regular

whether we should use deltaTime or unscaledDeltaTime;

◆ Velocity

Vector3 MoreMountains.Tools.MMSquashAndStretch.Velocity

the current velocity of the parent object

◆ VelocityMagnitude

float MoreMountains.Tools.MMSquashAndStretch.VelocityMagnitude

the current velocity magnitude

Property Documentation

◆ TimescaleDeltaTime

float? MoreMountains.Tools.MMSquashAndStretch.TimescaleDeltaTime
get

◆ TimescaleTime

float? MoreMountains.Tools.MMSquashAndStretch.TimescaleTime
get

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