TopDown Engine
v4.2
|
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...
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 |
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)
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.
|
protectedvirtual |
On Awake we initialize our magnetic enabler
|
protectedvirtual |
Grabs the collider2D and ensures it's set as trigger
|
protectedvirtual |
When something enters our trigger, if it's a proper target, we start following it
collider |
|
protectedvirtual |
When something enters our trigger 2D, if it's a proper target, we start following it
collider |
|
protectedvirtual |
If we trigger with a Magnetic, and the ID matches, we enable it
colliding |
|
protected |
|
protected |
float MoreMountains.TopDownEngine.MagneticEnabler.FollowAcceleration = 0.75f |
the value with which to override the acceleration
float MoreMountains.TopDownEngine.MagneticEnabler.FollowPositionSpeed = 5f |
the value with which to override the speed
List<int> MoreMountains.TopDownEngine.MagneticEnabler.MagneticTypeIDs |
a list of the magnetic type ID this enabler targets
bool MoreMountains.TopDownEngine.MagneticEnabler.OverrideFollowAcceleration = false |
if this is true, the acceleration will be overridden with the one specified here
bool MoreMountains.TopDownEngine.MagneticEnabler.OverrideFollowPositionSpeed = false |
if this is true, the follow position speed will be overridden with the one specified here
LayerMask MoreMountains.TopDownEngine.MagneticEnabler.TargetLayerMask = LayerManager.PlayerLayerMask |
the layermask this magnetic enabler looks at to enable magnetic elements