playMaker

Author Topic: Is there an action to continually update a trigger?  (Read 2880 times)

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Is there an action to continually update a trigger?
« on: September 15, 2014, 12:43:32 PM »
Hello!

I'm wondering if there's an action somewhere out there (or if one can be made, if possible) to have a trigger volume detected continually?

So, say this action is running... It's set to detect a trigger from a particular tag (assuming this object is going to be the one running into the tag) and update a boolean value (or another pertinent var but I think bool would be the ideal choice) as to whether that condition is met or not?

I know I could make another FSM that checks for that alone but I do want to try and keep this neat... I can work with that system for now but an action that would do something like this without having to transition to another state would be A+!

Edit: Though, is this something that the conditional expression action system would be able to work with or would it only be able to detect things like the usual variables? If it can handle trigger states, I'm all for that (I do love that action set! It's wonderful!)
« Last Edit: September 15, 2014, 12:45:06 PM by Red »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14832
  • Official Playmaker Support
    • View Profile
Re: Is there an action to continually update a trigger?
« Reply #1 on: September 23, 2014, 01:27:25 AM »
Hi,

 TriggerEvent Action is doing just that. I am not sure I understand your struggle here.

you enter a state, use TriggerEnter set to "OnTrigerExit" and it will fire an event if something exits the trigger.

 Bye,

 Jean

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: Is there an action to continually update a trigger?
« Reply #2 on: September 26, 2014, 12:20:39 PM »
Actually, what I'm looking for is an action that isn't going to require me to exit a particular state... Unless you're suggesting I use it only as a way to stash the actual collider it's interacting with instead of just making it not use the event dropdown and only use it to store the collider.

I'll give that a shot to see if I can work that in. Thank you.

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • View Profile
    • My Blog
Re: Is there an action to continually update a trigger?
« Reply #3 on: September 26, 2014, 05:36:37 PM »
You could set up an FSM with a public isTriggered bool, with the enter/exit states inside. But you're right. This could be useful to boil down into a single action.

TriggerEvent Action is doing just that. I am not sure I understand your struggle here.

He want's a similar action that outputs a boolean, instead of firing an event.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14832
  • Official Playmaker Support
    • View Profile
Re: Is there an action to continually update a trigger?
« Reply #4 on: October 05, 2014, 04:50:23 AM »
Hi,

 uhm, I see. good point. Keep bumping this, I'll do a set of actions to do that, cause I see some useful case for this. ( I think some bool actions and comparision could benefit from setting a variable instead of sending an event as well).

 Bye,

 Jean

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • View Profile
    • My Blog
Re: Is there an action to continually update a trigger?
« Reply #5 on: October 13, 2014, 06:10:47 AM »
Bump. I also would like to see comparisons return bools instead of events. Could be pretty useful  ;)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4649
    • View Profile
    • jinxtergames
Re: Is there an action to continually update a trigger?
« Reply #6 on: October 22, 2014, 05:19:27 AM »
Bump, oooo yes those can be very useful !
i am using a ton of triggers setting a bool which are used on enter and on exit to set a bool so now its 4 events needed to do that and then only 1 event can do the on enter and exit that would clean up a lot.

maybe it is possible to add them to the existing actions?
so it is even possible to set a bool and to send an event.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4649
    • View Profile
    • jinxtergames
Re: Is there an action to continually update a trigger?
« Reply #7 on: October 22, 2014, 05:53:06 AM »
i have been playing around with the trigger event to add a bool and i think this should work fine :
Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.

using System;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Physics)]
[Tooltip("Detect collisions with objects that have RigidBody components and set a bool. \nNOTE: The system events, TRIGGER ENTER, TRIGGER STAY, and TRIGGER EXIT are sent when any object collides with the trigger. Use this action to filter collisions by Tag.")]
public class TriggerEventAndBool : FsmStateAction
{

[UIHint(UIHint.Variable)]
public FsmBool boolVariable;
public FsmBool boolValue;

public TriggerType trigger;
[UIHint(UIHint.Tag)]
public FsmString collideTag;
public FsmEvent sendEvent;
[UIHint(UIHint.Variable)]
public FsmGameObject storeCollider;

public override void Reset()
{
boolVariable = null;
boolValue = null;

trigger = TriggerType.OnTriggerEnter;
collideTag = "Untagged";
sendEvent = null;
storeCollider = null;
}

public override void Awake()
{
switch (trigger)
{
case TriggerType.OnTriggerEnter:
Fsm.HandleTriggerEnter = true;
break;
case TriggerType.OnTriggerStay:
Fsm.HandleTriggerStay = true;
break;
case TriggerType.OnTriggerExit:
Fsm.HandleTriggerExit = true;
break;
}
}

void StoreCollisionInfo(Collider collisionInfo)
{
storeCollider.Value = collisionInfo.gameObject;
}

public override void DoTriggerEnter(Collider other)
{
if (trigger == TriggerType.OnTriggerEnter)
{
if (other.gameObject.tag == collideTag.Value)
{
boolVariable.Value = boolValue.Value;
StoreCollisionInfo(other);
Fsm.Event(sendEvent);
}
}
}

public override void DoTriggerStay(Collider other)
{
if (trigger == TriggerType.OnTriggerStay)
{
if (other.gameObject.tag == collideTag.Value)
{
boolVariable.Value = boolValue.Value;
StoreCollisionInfo(other);
Fsm.Event(sendEvent);
}
}
}

public override void DoTriggerExit(Collider other)
{
if (trigger == TriggerType.OnTriggerExit)
{
if (other.gameObject.tag == collideTag.Value)
{
boolVariable.Value = boolValue.Value;
StoreCollisionInfo(other);
Fsm.Event(sendEvent);
}
}
}

public override string ErrorCheck()
{
return ActionHelpers.CheckOwnerPhysicsSetup(Owner);
}


}
}

use @ your own risk :P