TopDown Engine  v3.6
MoreMountains.TopDownEngine.MagneticEnabler Class Reference

This object will enable Magnetic objects in your scene when they enter its associated collider2D (make sure you add one). While magnetic objects can work on their own, and handle their own range detection, you can also use a different architecture, where an enabler makes them move. A typical use case would be to add it to a character, nested under its top level : More...

Inheritance diagram for MoreMountains.TopDownEngine.MagneticEnabler:
MoreMountains.TopDownEngine.TopDownMonoBehaviour MoreMountains.Tools.MMMonoBehaviour

Public Attributes

LayerMask TargetLayerMask = LayerManager.PlayerLayerMask
 the layermask this magnetic enabler looks at to enable magnetic elements More...
 
List< int > MagneticTypeIDs
 a list of the magnetic type ID this enabler targets More...
 
bool OverrideFollowPositionSpeed = false
 if this is true, the follow position speed will be overridden with the one specified here More...
 
float FollowPositionSpeed = 5f
 the value with which to override the speed More...
 
bool OverrideFollowAcceleration = false
 if this is true, the acceleration will be overridden with the one specified here More...
 
float FollowAcceleration = 0.75f
 the value with which to override the acceleration More...
 

Protected Member Functions

virtual void Awake ()
 On Awake we initialize our magnetic enabler More...
 
virtual void Initialization ()
 Grabs the collider2D and ensures it's set as trigger More...
 
virtual void OnTriggerEnter2D (Collider2D colliding)
 When something enters our trigger 2D, if it's a proper target, we start 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 OnTriggerEnterInternal (GameObject colliding)
 If we trigger with a Magnetic, and the ID matches, we enable it More...
 

Protected Attributes

Collider2D _collider2D
 
Magnetic _magnetic
 

Detailed Description

This object will enable Magnetic objects in your scene when they enter its associated collider2D (make sure you add one). While magnetic objects can work on their own, and handle their own range detection, you can also use a different architecture, where an enabler makes them move. A typical use case would be to add it to a character, nested under its top level :

MyCharacter (top level, with a Character, controller, abilities, etc)

  • MyMagneticEnabler (with this class and a CircleCollider2D for example)

Then, in your scene you'd have Magnetic objects, with StartMagnetOnEnter disabled. Your magnetic enabler would make them follow this specific target on enter. From the enabler you can also have it override the follow speed and acceleration.

Member Function Documentation

◆ Awake()

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

On Awake we initialize our magnetic enabler

◆ Initialization()

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

Grabs the collider2D and ensures it's set as trigger

◆ OnTriggerEnter()

virtual void MoreMountains.TopDownEngine.MagneticEnabler.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.MagneticEnabler.OnTriggerEnter2D ( Collider2D  colliding)
protectedvirtual

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

Parameters
collider

◆ OnTriggerEnterInternal()

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

If we trigger with a Magnetic, and the ID matches, we enable it

Parameters
colliding

Member Data Documentation

◆ _collider2D

Collider2D MoreMountains.TopDownEngine.MagneticEnabler._collider2D
protected

◆ _magnetic

Magnetic MoreMountains.TopDownEngine.MagneticEnabler._magnetic
protected

◆ FollowAcceleration

float MoreMountains.TopDownEngine.MagneticEnabler.FollowAcceleration = 0.75f

the value with which to override the acceleration

◆ FollowPositionSpeed

float MoreMountains.TopDownEngine.MagneticEnabler.FollowPositionSpeed = 5f

the value with which to override the speed

◆ MagneticTypeIDs

List<int> MoreMountains.TopDownEngine.MagneticEnabler.MagneticTypeIDs

a list of the magnetic type ID this enabler targets

◆ OverrideFollowAcceleration

bool MoreMountains.TopDownEngine.MagneticEnabler.OverrideFollowAcceleration = false

if this is true, the acceleration will be overridden with the one specified here

◆ OverrideFollowPositionSpeed

bool MoreMountains.TopDownEngine.MagneticEnabler.OverrideFollowPositionSpeed = false

if this is true, the follow position speed will be overridden with the one specified here

◆ TargetLayerMask

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

the layermask this magnetic enabler looks at to enable magnetic elements


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