Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: szomaza on March 11, 2016, 02:19:26 AM

Title: Every Frame in Send Event does not seem to work
Post by: szomaza on March 11, 2016, 02:19:26 AM
Hi,

I am trying to use the Send Event
https://hutonggames.fogbugz.com/default.asp?W34
with the Every Frame ticked but it only sends the event once.

The send Event code looks like this:

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.

using System;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.StateMachine)]
[Tooltip("Sends an Event after an optional delay. NOTE: To send events between FSMs they must be marked as Global in the Events Browser.")]
public class SendEvent : FsmStateAction
{
[Tooltip("Where to send the event.")]
public FsmEventTarget eventTarget;

[RequiredField]
[Tooltip("The event to send. NOTE: Events must be marked Global to send between FSMs.")]
public FsmEvent sendEvent;

[HasFloatSlider(0, 10)]
[Tooltip("Optional delay in seconds.")]
public FsmFloat delay;

[Tooltip("Repeat every frame. Rarely needed.")]
public bool everyFrame;

private DelayedEvent delayedEvent;

public override void Reset()
{
eventTarget = null;
sendEvent = null;
delay = null;
everyFrame = false;
}

public override void OnEnter()
{
if (delay.Value < 0.001f)
{
Fsm.Event(eventTarget, sendEvent);
Finish();
}
else
{
delayedEvent = Fsm.DelayedEvent(eventTarget, sendEvent, delay.Value);
}
}

public override void OnUpdate()
{
if (!everyFrame)
{
if (DelayedEvent.WasSent(delayedEvent))
{
Finish();
}
}
}
}
}

Am I right that there is this line missing from the OnUpdate part?
Fsm.Event(eventTarget, sendEvent);
before checking for    if (!everyFrame)

Br,
szomaza with Playmaker 1.7.8.3p2
Title: Re: Every Frame in Send Event does not seem to work
Post by: szomaza on April 04, 2016, 01:54:42 AM
Please take a short look at this and shed some light if I should simply add that one line to make it work, or am I doing something wrong!?
Title: Re: Every Frame in Send Event does not seem to work
Post by: jeanfabre on April 04, 2016, 02:09:41 AM
Hi,

 This is not the same code I have here, where did you get that?

Get the latest from the Asset Store, you should have 1.7.8.4 let me know if the code is still the same.

you should have on update:

Code: [Select]
public override void OnUpdate()
{
if (!everyFrame)
{
if (DelayedEvent.WasSent(delayedEvent))
{
Finish();
}
}
else
{
                              Fsm.Event(eventTarget, sendEvent);
}
}

Bye,

 Jean
Title: Re: Every Frame in Send Event does not seem to work
Post by: szomaza on April 06, 2016, 12:31:24 AM
Thank Jean for replying.
That code is from  Playmaker 1.7.8.3p2.

I'll change that locally for now and then get around to updating, maybe on next weekend.

I'll tell you what I see after the update.

Br,
szomaza