Created
September 28, 2017 02:59
-
-
Save willt/80389584e207398f1209d9fcb699ef8f to your computer and use it in GitHub Desktop.
Removes a collider mask from a Platform Effector 2d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
namespace HutongGames.PlayMaker.Actions | |
{ | |
[ActionCategory(ActionCategory.Physics2D)] | |
[Tooltip("Removes a collider mask from a Platform Effector 2d")] | |
public class RemovePlatformEffector2DColliderMask : FsmStateAction | |
{ | |
[RequiredField] | |
[CheckForComponent(typeof(PlatformEffector2D))] | |
[Tooltip("The GameObject with the PlatformEffector2D attached")] | |
public FsmOwnerDefault gameObject; | |
[UIHint(UIHint.Layer)] | |
[Tooltip("The collision layer to remove")] | |
public int collisionLayer; | |
public override void Reset() | |
{ | |
gameObject = null; | |
collisionLayer = 0; | |
} | |
public override void OnUpdate() | |
{ | |
DoRemoveMask(); | |
Finish(); | |
} | |
void DoRemoveMask() | |
{ | |
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); | |
if (go == null) return; | |
PlatformEffector2D pe = go.GetComponent<PlatformEffector2D>(); | |
if (pe != null) | |
{ | |
pe.colliderMask ^= (1 << collisionLayer); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment