Corgi Engine  v9.1
MoreMountains.CorgiEngine.Magnetic Class Reference
Inheritance diagram for MoreMountains.CorgiEngine.Magnetic:
MoreMountains.CorgiEngine.CorgiMonoBehaviour

Public Types

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

Public Member Functions

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 Initialization ()
 Grabs the collider2D 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
 
Vector3 _velocity = Vector3.zero
 
Vector3 _newTargetPosition
 
Vector3 _lastTargetPosition
 
Vector3 _direction
 
Vector3 _newPosition
 
float _speed
 

Member Enumeration Documentation

◆ UpdateModes

the possible update modes

Enumerator
Update 
FixedUpdate 
LateUpdate 

Member Function Documentation

◆ Awake()

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

On Awake we initialize our magnet

◆ FixedUpdate()

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

At fixed update we follow our target

◆ FollowTargetPosition()

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

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

◆ Initialization()

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

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

◆ LateUpdate()

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

At late update we follow our target

◆ OnTriggerEnter()

virtual void MoreMountains.CorgiEngine.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.CorgiEngine.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.CorgiEngine.Magnetic.OnTriggerEnterInternal ( GameObject  colliding)
protectedvirtual

Starts following an object we trigger with if conditions are met

Parameters
colliding

◆ OnTriggerExit()

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

When something exits our trigger, we stop following it

Parameters
collider

◆ OnTriggerExit2D()

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

When something exits our trigger, we stop following it

Parameters
collider

◆ OnTriggerExitInternal()

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

Stops following an object we trigger with if conditions are met

Parameters
colliding

◆ SetTarget()

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

Sets a new target for this object to magnet towards

Parameters
newTarget

◆ StartFollowing()

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

Makes the object follow the target

◆ StopFollowing()

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

Prevents the object from following the target anymore

◆ Update()

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

At update we follow our target

Member Data Documentation

◆ _collider2D

Collider2D MoreMountains.CorgiEngine.Magnetic._collider2D
protected

◆ _direction

Vector3 MoreMountains.CorgiEngine.Magnetic._direction
protected

◆ _lastTargetPosition

Vector3 MoreMountains.CorgiEngine.Magnetic._lastTargetPosition
protected

◆ _newPosition

Vector3 MoreMountains.CorgiEngine.Magnetic._newPosition
protected

◆ _newTargetPosition

Vector3 MoreMountains.CorgiEngine.Magnetic._newTargetPosition
protected

◆ _speed

float MoreMountains.CorgiEngine.Magnetic._speed
protected

◆ _velocity

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

◆ CopyState

GameObject MoreMountains.CorgiEngine.Magnetic.CopyState

an object this magnetic object should copy the active state on

◆ FollowAcceleration

float MoreMountains.CorgiEngine.Magnetic.FollowAcceleration = 0.75f

the acceleration to apply to the object once it starts following

◆ FollowPosition

bool MoreMountains.CorgiEngine.Magnetic.FollowPosition = true

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

◆ FollowPositionSpeed

float MoreMountains.CorgiEngine.Magnetic.FollowPositionSpeed = 5f

the speed at which to interpolate the follower's movement

◆ InterpolatePosition

bool MoreMountains.CorgiEngine.Magnetic.InterpolatePosition = true

whether or not we need to interpolate the movement

◆ MagneticTypeID

int MoreMountains.CorgiEngine.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.CorgiEngine.Magnetic.Offset

the offset to apply to the followed target

◆ StartMagnetOnEnter

bool MoreMountains.CorgiEngine.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.CorgiEngine.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.CorgiEngine.Magnetic.Target

the target to follow, read only, for debug only

◆ TargetLayerMask

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

the layermask this magnetic element is attracted to

◆ UpdateMode

UpdateModes MoreMountains.CorgiEngine.Magnetic.UpdateMode = UpdateModes.Update

the update at which the movement happens


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