TopDown Engine  v4.2
MoreMountains.TopDownEngine.Magnetic Class Reference
Inheritance diagram for MoreMountains.TopDownEngine.Magnetic:
MoreMountains.TopDownEngine.TopDownMonoBehaviour MoreMountains.Tools.MMMonoBehaviour

Public Types

enum  UpdateModes { UpdateModes.Update, UpdateModes.FixedUpdate, UpdateModes.LateUpdate }
 the possible update modes More...
 

Public Member Functions

virtual void Reset ()
 Call this to reset the target and speed of this magnetic object More...
 
virtual void ResetPosition ()
 Call this to reset the position of the magnetic to its initial position 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 SetTarget (Transform newTarget)
 Sets a new target for this object to magnet towards More...
 

Public Attributes

LayerMask TargetLayerMask = LayerManager.PlayerLayerMask
 the layermask this magnetic element is attracted to More...
 
bool StartMagnetOnEnter = true
 whether or not to start moving when something on the target layer mask enters this magnetic element's trigger More...
 
bool StopMagnetOnExit = false
 whether or not to stop moving when something on the target layer mask exits this magnetic element's trigger More...
 
int MagneticTypeID = 0
 a unique ID for this type of magnetic objects. This can then be used by a MagneticEnabler to target only that specific ID. An ID of 0 will be picked by all MagneticEnablers automatically. More...
 
Vector3 Offset
 the offset to apply to the followed target More...
 
bool InterpolatePosition = true
 whether or not we need to interpolate the movement More...
 
float FollowPositionSpeed = 5f
 the speed at which to interpolate the follower's movement More...
 
float FollowAcceleration = 0.75f
 the acceleration to apply to the object once it starts following More...
 
UpdateModes UpdateMode = UpdateModes.Update
 the update at which the movement happens More...
 
GameObject CopyState
 an object this magnetic object should copy the active state on More...
 
Transform Target
 the target to follow, read only, for debug only More...
 
bool FollowPosition = true
 whether or not the object is currently following its target's position More...
 

Protected Member Functions

virtual void Awake ()
 On Awake we initialize our magnet More...
 
virtual void OnEnable ()
 
virtual void Initialization ()
 Grabs the collider and ensures it's set as trigger, initializes the speed More...
 
virtual void OnTriggerEnter2D (Collider2D colliding)
 When something enters our trigger, if it's a proper target, we start following it More...
 
virtual void OnTriggerExit2D (Collider2D colliding)
 When something exits our trigger, we stop following it More...
 
virtual void OnTriggerEnter (Collider colliding)
 When something enters our trigger, if it's a proper target, we start following it More...
 
virtual void OnTriggerExit (Collider colliding)
 When something exits our trigger, we stop following it More...
 
virtual void OnTriggerEnterInternal (GameObject colliding)
 Starts following an object we trigger with if conditions are met More...
 
virtual void OnTriggerExitInternal (GameObject colliding)
 Stops following an object we trigger with if conditions are met 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...
 

Protected Attributes

Collider2D _collider2D
 
Collider _collider
 
Vector3 _velocity = Vector3.zero
 
Vector3 _newTargetPosition
 
Vector3 _lastTargetPosition
 
Vector3 _direction
 
Vector3 _newPosition
 
float _speed
 
Vector3 _initialPosition
 

Member Enumeration Documentation

◆ UpdateModes

the possible update modes

Enumerator
Update 
FixedUpdate 
LateUpdate 

Member Function Documentation

◆ Awake()

virtual void MoreMountains.TopDownEngine.Magnetic.Awake ( )
protectedvirtual

On Awake we initialize our magnet

◆ FixedUpdate()

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

At fixed update we follow our target

◆ FollowTargetPosition()

virtual void MoreMountains.TopDownEngine.Magnetic.FollowTargetPosition ( )
protectedvirtual

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

◆ Initialization()

virtual void MoreMountains.TopDownEngine.Magnetic.Initialization ( )
protectedvirtual

Grabs the collider and ensures it's set as trigger, initializes the speed

◆ LateUpdate()

virtual void MoreMountains.TopDownEngine.Magnetic.LateUpdate ( )
protectedvirtual

At late update we follow our target

◆ OnEnable()

virtual void MoreMountains.TopDownEngine.Magnetic.OnEnable ( )
protectedvirtual

◆ OnTriggerEnter()

virtual void MoreMountains.TopDownEngine.Magnetic.OnTriggerEnter ( Collider  colliding)
protectedvirtual

When something enters our trigger, if it's a proper target, we start following it

Parameters
collider

◆ OnTriggerEnter2D()

virtual void MoreMountains.TopDownEngine.Magnetic.OnTriggerEnter2D ( Collider2D  colliding)
protectedvirtual

When something enters our trigger, if it's a proper target, we start following it

Parameters
collider

◆ OnTriggerEnterInternal()

virtual void MoreMountains.TopDownEngine.Magnetic.OnTriggerEnterInternal ( GameObject  colliding)
protectedvirtual

Starts following an object we trigger with if conditions are met

Parameters
colliding

◆ OnTriggerExit()

virtual void MoreMountains.TopDownEngine.Magnetic.OnTriggerExit ( Collider  colliding)
protectedvirtual

When something exits our trigger, we stop following it

Parameters
collider

◆ OnTriggerExit2D()

virtual void MoreMountains.TopDownEngine.Magnetic.OnTriggerExit2D ( Collider2D  colliding)
protectedvirtual

When something exits our trigger, we stop following it

Parameters
collider

◆ OnTriggerExitInternal()

virtual void MoreMountains.TopDownEngine.Magnetic.OnTriggerExitInternal ( GameObject  colliding)
protectedvirtual

Stops following an object we trigger with if conditions are met

Parameters
colliding

◆ Reset()

virtual void MoreMountains.TopDownEngine.Magnetic.Reset ( )
virtual

Call this to reset the target and speed of this magnetic object

◆ ResetPosition()

virtual void MoreMountains.TopDownEngine.Magnetic.ResetPosition ( )
virtual

Call this to reset the position of the magnetic to its initial position

◆ SetTarget()

virtual void MoreMountains.TopDownEngine.Magnetic.SetTarget ( Transform  newTarget)
virtual

Sets a new target for this object to magnet towards

Parameters
newTarget

◆ StartFollowing()

virtual void MoreMountains.TopDownEngine.Magnetic.StartFollowing ( )
virtual

Makes the object follow the target

◆ StopFollowing()

virtual void MoreMountains.TopDownEngine.Magnetic.StopFollowing ( )
virtual

Prevents the object from following the target anymore

◆ Update()

virtual void MoreMountains.TopDownEngine.Magnetic.Update ( )
protectedvirtual

At update we follow our target

Member Data Documentation

◆ _collider

Collider MoreMountains.TopDownEngine.Magnetic._collider
protected

◆ _collider2D

Collider2D MoreMountains.TopDownEngine.Magnetic._collider2D
protected

◆ _direction

Vector3 MoreMountains.TopDownEngine.Magnetic._direction
protected

◆ _initialPosition

Vector3 MoreMountains.TopDownEngine.Magnetic._initialPosition
protected

◆ _lastTargetPosition

Vector3 MoreMountains.TopDownEngine.Magnetic._lastTargetPosition
protected

◆ _newPosition

Vector3 MoreMountains.TopDownEngine.Magnetic._newPosition
protected

◆ _newTargetPosition

Vector3 MoreMountains.TopDownEngine.Magnetic._newTargetPosition
protected

◆ _speed

float MoreMountains.TopDownEngine.Magnetic._speed
protected

◆ _velocity

Vector3 MoreMountains.TopDownEngine.Magnetic._velocity = Vector3.zero
protected

◆ CopyState

GameObject MoreMountains.TopDownEngine.Magnetic.CopyState

an object this magnetic object should copy the active state on

◆ FollowAcceleration

float MoreMountains.TopDownEngine.Magnetic.FollowAcceleration = 0.75f

the acceleration to apply to the object once it starts following

◆ FollowPosition

bool MoreMountains.TopDownEngine.Magnetic.FollowPosition = true

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

◆ FollowPositionSpeed

float MoreMountains.TopDownEngine.Magnetic.FollowPositionSpeed = 5f

the speed at which to interpolate the follower's movement

◆ InterpolatePosition

bool MoreMountains.TopDownEngine.Magnetic.InterpolatePosition = true

whether or not we need to interpolate the movement

◆ MagneticTypeID

int MoreMountains.TopDownEngine.Magnetic.MagneticTypeID = 0

a unique ID for this type of magnetic objects. This can then be used by a MagneticEnabler to target only that specific ID. An ID of 0 will be picked by all MagneticEnablers automatically.

◆ Offset

Vector3 MoreMountains.TopDownEngine.Magnetic.Offset

the offset to apply to the followed target

◆ StartMagnetOnEnter

bool MoreMountains.TopDownEngine.Magnetic.StartMagnetOnEnter = true

whether or not to start moving when something on the target layer mask enters this magnetic element's trigger

◆ StopMagnetOnExit

bool MoreMountains.TopDownEngine.Magnetic.StopMagnetOnExit = false

whether or not to stop moving when something on the target layer mask exits this magnetic element's trigger

◆ Target

Transform MoreMountains.TopDownEngine.Magnetic.Target

the target to follow, read only, for debug only

◆ TargetLayerMask

LayerMask MoreMountains.TopDownEngine.Magnetic.TargetLayerMask = LayerManager.PlayerLayerMask

the layermask this magnetic element is attracted to

◆ UpdateMode

UpdateModes MoreMountains.TopDownEngine.Magnetic.UpdateMode = UpdateModes.Update

the update at which the movement happens


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