PlayMaker Updates & Downloads > Share New Actions
ToggleIsTrigger
(1/1)
jeanfabre:
Hi,
More on isTrigger with this toggle action ( following Marcos's request).
--- Code: --- // (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Physics)]
[Tooltip("Toggle a collider isTrigger Flag")]
public class ToggleIsTrigger : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(Collider))]
public FsmOwnerDefault gameObject;
public override void Reset()
{
gameObject = null;
}
public override void OnEnter()
{
DoToggleIsTrigger();
Finish();
}
void DoToggleIsTrigger()
{
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null) return;
if (go.collider == null) return;
go.collider.isTrigger = !go.collider.isTrigger;
}
}
}
--- End code ---
Bye,
Jean
MaDDoX:
Very nice and quick "action reply", thanks :)
Navigation
[0] Message Index
Go to full version