Created
September 28, 2017 03:00
-
-
Save willt/c9f2c2326e64c45895b357e2a6ce46b9 to your computer and use it in GitHub Desktop.
Adds a collider mask to 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("Adds a collider mask to a Platform Effector 2D")] | |
public class AddPlatformEffector2DColliderMask : FsmStateAction | |
{ | |
[RequiredField] | |
[CheckForComponent(typeof(PlatformEffector2D))] | |
[Tooltip("The GameObject with the PlatformEffector2D attached")] | |
public FsmOwnerDefault gameObject; | |
[UIHint(UIHint.Layer)] | |
[Tooltip("The collision layer to add")] | |
public int collisionLayer; | |
public override void Reset() | |
{ | |
gameObject = null; | |
collisionLayer = 0; | |
} | |
public override void OnUpdate() | |
{ | |
DoAddMask(); | |
Finish(); | |
} | |
void DoAddMask() | |
{ | |
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