playMaker

Author Topic: ToggleIsTrigger  (Read 1729 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
ToggleIsTrigger
« on: May 09, 2011, 11:52:34 PM »
Hi,
 
 More on isTrigger with this toggle action ( following Marcos's request).

Code: [Select]
// (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;
}
}
}

Bye,

 Jean
 

MaDDoX

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 165
    • View Profile
    • FluidPlay Studios
Re: ToggleIsTrigger
« Reply #1 on: May 10, 2011, 04:20:49 AM »
Very nice and quick "action reply", thanks :)
--
Breno "MaDDoX" Azevedo
@brenoazevedo