Hi,
You beat me to it
Nice actions!
But OnUpdate is usually used if there is an 'every frame' option
Try looking to other actions how they are setup
I checked them out and i have rebuild it into a single action, if you like it i can add it to the ecosystem.
// (c) Copyright HutongGames, LLC 2010-2017. All rights reserved.
/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/
//author : zeeawk
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Physics2D)]
[Tooltip("Adds a collider mask to a Platform Effector 2D")]
public class SetPlatformEffector2DColliderMask : FsmStateAction
{
public enum Operation
{
Enable,
Disable
}
[RequiredField]
[CheckForComponent(typeof(PlatformEffector2D))]
[Tooltip("The GameObject with the PlatformEffector2D attached")]
public FsmOwnerDefault gameObject;
[UIHint(UIHint.Layer)]
[Tooltip("The collision layer to add or remove")]
public int collisionLayer;
[Tooltip("Add or Remove the collision layer")]
public Operation operation = Operation.Enable;
[Tooltip("Reset when exiting this state.")]
public FsmBool resetOnExit;
PlatformEffector2D pe;
public override void Reset()
{
gameObject = null;
collisionLayer = 0;
operation = Operation.Enable;
resetOnExit = false;
}
public override void OnEnter()
{
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null) return;
pe = go.GetComponent<PlatformEffector2D>();
if (pe != null)
{
switch (operation)
{
case Operation.Enable:
Enable();
break;
case Operation.Disable:
Disable();
break;
}
Finish();
}
}
public override void OnExit()
{
if (pe != null)
{
switch (operation)
{
case Operation.Enable:
pe.colliderMask ^= (1 << collisionLayer);
break;
case Operation.Disable:
Enable();
break;
}
}
}
void Enable()
{
pe.colliderMask |= (1 << collisionLayer);
}
void Disable()
{
pe.colliderMask ^= (1 << collisionLayer);
}
}
}
Instead of the Enum i could use an fsmbool (Named 'Enable') but i think this look better
If your are planning to make more actions and want to submit to the Ecosytem, let me know so i can contact Jean to give you access or you can
contact jean directly.