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

Add this component to an object and it'll get moved towards the target at update, with or without interpolation based on your settings More...

Inheritance diagram for MoreMountains.Tools.MMFollowTarget:

Public Types

enum  UpdateModes { Update , FixedUpdate , LateUpdate }
 the possible update modes More...
 
enum  FollowModes { RegularLerp , MMLerp , MMSpring }
 the possible follow modes More...
 
enum  PositionSpaces { World , Local }
 whether to operate in world or local space More...
 

Public Member Functions

virtual void Initialization ()
 Initializes the follow More...
 
virtual void StopFollowing ()
 Prevents the object from following the target anymore More...
 
virtual void StartFollowing ()
 Makes the object follow the target More...
 
virtual void ChangeFollowTarget (Transform newTarget)
 

Public Attributes

bool FollowPosition = true
 whether or not the object is currently following its target's position More...
 
bool FollowPositionX = true
 whether this object should follow its target on the X axis More...
 
bool FollowPositionY = true
 whether this object should follow its target on the Y axis More...
 
bool FollowPositionZ = true
 whether this object should follow its target on the Z axis More...
 
PositionSpaces PositionSpace = PositionSpaces.World
 whether to operate in world or local space More...
 
bool FollowRotation = true
 whether or not the object is currently following its target's rotation More...
 
bool FollowScale = true
 whether or not the object is currently following its target's rotation More...
 
float FollowScaleFactor = 1f
 the factor to apply to the scale when following More...
 
Transform Target
 the target to follow More...
 
Vector3 Offset
 the offset to apply to the followed target More...
 
bool AddInitialDistanceXToXOffset = false
 whether or not to add the initial x distance to the offset More...
 
bool AddInitialDistanceYToYOffset = false
 whether or not to add the initial y distance to the offset More...
 
bool AddInitialDistanceZToZOffset = false
 whether or not to add the initial z distance to the offset More...
 
bool InterpolatePosition = true
 whether or not we need to interpolate the movement More...
 
FollowModes FollowPositionMode = FollowModes.MMLerp
 the follow mode to use when following position More...
 
float FollowPositionSpeed = 10f
 the speed at which to interpolate the follower's movement More...
 
float PositionSpringDamping = 0.3f
 higher values mean more damping, less spring, low values mean less damping, more spring More...
 
float PositionSpringFrequency = 3f
 the frequency at which the spring should "vibrate", in Hz (1 : the spring will do one full period in one second) More...
 
bool InterpolateRotation = true
 whether or not we need to interpolate the movement More...
 
FollowModes FollowRotationMode = FollowModes.MMLerp
 the follow mode to use when interpolating the rotation More...
 
float FollowRotationSpeed = 10f
 the speed at which to interpolate the follower's rotation More...
 
bool InterpolateScale = true
 whether or not we need to interpolate the scale More...
 
FollowModes FollowScaleMode = FollowModes.MMLerp
 the follow mode to use when interpolating the scale More...
 
float FollowScaleSpeed = 10f
 the speed at which to interpolate the follower's scale More...
 
UpdateModes UpdateMode = UpdateModes.Update
 the update at which the movement happens More...
 
bool UseMinimumDistanceBeforeFollow = false
 whether or not to force a minimum distance between the object and its target before it starts following More...
 
float MinimumDistanceBeforeFollow = 1f
 the minimum distance to keep between the object and its target More...
 
bool UseMaximumDistance = false
 whether or not we want to make sure the object is never too far away from its target More...
 
float MaximumDistance = 1f
 the maximum distance at which the object can be away from its target More...
 
bool AnchorToInitialPosition
 if this is true, the movement will be constrained around the initial position More...
 
float MaxDistanceToAnchor = 1f
 the maximum distance around the initial position at which the transform can move More...
 

Protected Member Functions

virtual void Start ()
 On start we store our initial position More...
 
virtual void SetInitialPosition ()
 Stores the initial position More...
 
virtual void SetOffset ()
 Adds initial offset to the offset if needed More...
 
virtual void Update ()
 At update we follow our target More...
 
virtual void FixedUpdate ()
 At fixed update we follow our target More...
 
virtual void LateUpdate ()
 At late update we follow our target More...
 
virtual void FollowTargetPosition ()
 Follows the target, lerping the position or not based on what's been defined in the inspector More...
 
virtual float ApplyMinMaxDistancing (float trueDistance, float interpolatedDistance)
 Applies minimal and maximal distance rules to the interpolated distance More...
 
virtual void FollowTargetRotation ()
 Makes the object follow its target's rotation More...
 
virtual void FollowTargetScale ()
 Makes the object follow its target's scale More...
 

Protected Attributes

Vector3 _velocity = Vector3.zero
 
Vector3 _newTargetPosition
 
Vector3 _initialPosition
 
Vector3 _lastTargetPosition
 
Vector3 _direction
 
Vector3 _newPosition
 
Vector3 _newScale
 
Quaternion _newTargetRotation
 
Quaternion _initialRotation
 

Properties

bool _localSpace [get]
 

Detailed Description

Add this component to an object and it'll get moved towards the target at update, with or without interpolation based on your settings

Member Enumeration Documentation

◆ FollowModes

the possible follow modes

Enumerator
RegularLerp 
MMLerp 
MMSpring 

◆ PositionSpaces

whether to operate in world or local space

Enumerator
World 
Local 

◆ UpdateModes

the possible update modes

Enumerator
Update 
FixedUpdate 
LateUpdate 

Member Function Documentation

◆ ApplyMinMaxDistancing()

virtual float MoreMountains.Tools.MMFollowTarget.ApplyMinMaxDistancing ( float  trueDistance,
float  interpolatedDistance 
)
protectedvirtual

Applies minimal and maximal distance rules to the interpolated distance

Parameters
trueDistance
interpolatedDistance
Returns

◆ ChangeFollowTarget()

virtual void MoreMountains.Tools.MMFollowTarget.ChangeFollowTarget ( Transform  newTarget)
virtual

◆ FixedUpdate()

virtual void MoreMountains.Tools.MMFollowTarget.FixedUpdate ( )
protectedvirtual

At fixed update we follow our target

◆ FollowTargetPosition()

virtual void MoreMountains.Tools.MMFollowTarget.FollowTargetPosition ( )
protectedvirtual

Follows the target, lerping the position or not based on what's been defined in the inspector

◆ FollowTargetRotation()

virtual void MoreMountains.Tools.MMFollowTarget.FollowTargetRotation ( )
protectedvirtual

Makes the object follow its target's rotation

◆ FollowTargetScale()

virtual void MoreMountains.Tools.MMFollowTarget.FollowTargetScale ( )
protectedvirtual

Makes the object follow its target's scale

◆ Initialization()

virtual void MoreMountains.Tools.MMFollowTarget.Initialization ( )
virtual

Initializes the follow

◆ LateUpdate()

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

At late update we follow our target

◆ SetInitialPosition()

virtual void MoreMountains.Tools.MMFollowTarget.SetInitialPosition ( )
protectedvirtual

Stores the initial position

◆ SetOffset()

virtual void MoreMountains.Tools.MMFollowTarget.SetOffset ( )
protectedvirtual

Adds initial offset to the offset if needed

◆ Start()

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

On start we store our initial position

◆ StartFollowing()

virtual void MoreMountains.Tools.MMFollowTarget.StartFollowing ( )
virtual

Makes the object follow the target

◆ StopFollowing()

virtual void MoreMountains.Tools.MMFollowTarget.StopFollowing ( )
virtual

Prevents the object from following the target anymore

◆ Update()

virtual void MoreMountains.Tools.MMFollowTarget.Update ( )
protectedvirtual

At update we follow our target

Member Data Documentation

◆ _direction

Vector3 MoreMountains.Tools.MMFollowTarget._direction
protected

◆ _initialPosition

Vector3 MoreMountains.Tools.MMFollowTarget._initialPosition
protected

◆ _initialRotation

Quaternion MoreMountains.Tools.MMFollowTarget._initialRotation
protected

◆ _lastTargetPosition

Vector3 MoreMountains.Tools.MMFollowTarget._lastTargetPosition
protected

◆ _newPosition

Vector3 MoreMountains.Tools.MMFollowTarget._newPosition
protected

◆ _newScale

Vector3 MoreMountains.Tools.MMFollowTarget._newScale
protected

◆ _newTargetPosition

Vector3 MoreMountains.Tools.MMFollowTarget._newTargetPosition
protected

◆ _newTargetRotation

Quaternion MoreMountains.Tools.MMFollowTarget._newTargetRotation
protected

◆ _velocity

Vector3 MoreMountains.Tools.MMFollowTarget._velocity = Vector3.zero
protected

◆ AddInitialDistanceXToXOffset

bool MoreMountains.Tools.MMFollowTarget.AddInitialDistanceXToXOffset = false

whether or not to add the initial x distance to the offset

◆ AddInitialDistanceYToYOffset

bool MoreMountains.Tools.MMFollowTarget.AddInitialDistanceYToYOffset = false

whether or not to add the initial y distance to the offset

◆ AddInitialDistanceZToZOffset

bool MoreMountains.Tools.MMFollowTarget.AddInitialDistanceZToZOffset = false

whether or not to add the initial z distance to the offset

◆ AnchorToInitialPosition

bool MoreMountains.Tools.MMFollowTarget.AnchorToInitialPosition

if this is true, the movement will be constrained around the initial position

◆ FollowPosition

bool MoreMountains.Tools.MMFollowTarget.FollowPosition = true

whether or not the object is currently following its target's position

◆ FollowPositionMode

FollowModes MoreMountains.Tools.MMFollowTarget.FollowPositionMode = FollowModes.MMLerp

the follow mode to use when following position

◆ FollowPositionSpeed

float MoreMountains.Tools.MMFollowTarget.FollowPositionSpeed = 10f

the speed at which to interpolate the follower's movement

◆ FollowPositionX

bool MoreMountains.Tools.MMFollowTarget.FollowPositionX = true

whether this object should follow its target on the X axis

◆ FollowPositionY

bool MoreMountains.Tools.MMFollowTarget.FollowPositionY = true

whether this object should follow its target on the Y axis

◆ FollowPositionZ

bool MoreMountains.Tools.MMFollowTarget.FollowPositionZ = true

whether this object should follow its target on the Z axis

◆ FollowRotation

bool MoreMountains.Tools.MMFollowTarget.FollowRotation = true

whether or not the object is currently following its target's rotation

◆ FollowRotationMode

FollowModes MoreMountains.Tools.MMFollowTarget.FollowRotationMode = FollowModes.MMLerp

the follow mode to use when interpolating the rotation

◆ FollowRotationSpeed

float MoreMountains.Tools.MMFollowTarget.FollowRotationSpeed = 10f

the speed at which to interpolate the follower's rotation

◆ FollowScale

bool MoreMountains.Tools.MMFollowTarget.FollowScale = true

whether or not the object is currently following its target's rotation

◆ FollowScaleFactor

float MoreMountains.Tools.MMFollowTarget.FollowScaleFactor = 1f

the factor to apply to the scale when following

◆ FollowScaleMode

FollowModes MoreMountains.Tools.MMFollowTarget.FollowScaleMode = FollowModes.MMLerp

the follow mode to use when interpolating the scale

◆ FollowScaleSpeed

float MoreMountains.Tools.MMFollowTarget.FollowScaleSpeed = 10f

the speed at which to interpolate the follower's scale

◆ InterpolatePosition

bool MoreMountains.Tools.MMFollowTarget.InterpolatePosition = true

whether or not we need to interpolate the movement

◆ InterpolateRotation

bool MoreMountains.Tools.MMFollowTarget.InterpolateRotation = true

whether or not we need to interpolate the movement

◆ InterpolateScale

bool MoreMountains.Tools.MMFollowTarget.InterpolateScale = true

whether or not we need to interpolate the scale

◆ MaxDistanceToAnchor

float MoreMountains.Tools.MMFollowTarget.MaxDistanceToAnchor = 1f

the maximum distance around the initial position at which the transform can move

◆ MaximumDistance

float MoreMountains.Tools.MMFollowTarget.MaximumDistance = 1f

the maximum distance at which the object can be away from its target

◆ MinimumDistanceBeforeFollow

float MoreMountains.Tools.MMFollowTarget.MinimumDistanceBeforeFollow = 1f

the minimum distance to keep between the object and its target

◆ Offset

Vector3 MoreMountains.Tools.MMFollowTarget.Offset

the offset to apply to the followed target

◆ PositionSpace

PositionSpaces MoreMountains.Tools.MMFollowTarget.PositionSpace = PositionSpaces.World

whether to operate in world or local space

◆ PositionSpringDamping

float MoreMountains.Tools.MMFollowTarget.PositionSpringDamping = 0.3f

higher values mean more damping, less spring, low values mean less damping, more spring

◆ PositionSpringFrequency

float MoreMountains.Tools.MMFollowTarget.PositionSpringFrequency = 3f

the frequency at which the spring should "vibrate", in Hz (1 : the spring will do one full period in one second)

◆ Target

Transform MoreMountains.Tools.MMFollowTarget.Target

the target to follow

◆ UpdateMode

UpdateModes MoreMountains.Tools.MMFollowTarget.UpdateMode = UpdateModes.Update

the update at which the movement happens

◆ UseMaximumDistance

bool MoreMountains.Tools.MMFollowTarget.UseMaximumDistance = false

whether or not we want to make sure the object is never too far away from its target

◆ UseMinimumDistanceBeforeFollow

bool MoreMountains.Tools.MMFollowTarget.UseMinimumDistanceBeforeFollow = false

whether or not to force a minimum distance between the object and its target before it starts following

Property Documentation

◆ _localSpace

bool MoreMountains.Tools.MMFollowTarget._localSpace
getprotected

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