unity-experiment-framework icon indicating copy to clipboard operation
unity-experiment-framework copied to clipboard

Is there a way to run an animation after the last trial on Block?

Open rmib200 opened this issue 2 years ago • 3 comments

I want to run an animation when the experiment reaches the last trial in each block but I can't seem to make it work. I tried using the OnSessionEnd, PreSessionEnd events to trigger the animation but it doesn't work. Is like the events occurs too fast. Maybe I'm messing up in something simple but I couldn't figure out completely. Any help would be really appreciated.

rmib200 avatar Jun 08 '22 03:06 rmib200

OnSessionEnd works at the end of each session, not block. You need to use OnTrialEnd and check if it the final trial in the block:

// assign to OnTrialEnd
public void TriggerAnimationIfLastTrialInBlock(UXF.Trial trial)
{
    if (trial == trial.block.lastTrial)
    {
        // trigger animation
    }
}

jackbrookes avatar Jun 08 '22 15:06 jackbrookes

Thank you, it really helped to set some things. But the error I'm still having is that the next block start too fast. Is there any way to control that?

rmib200 avatar Jun 10 '22 22:06 rmib200

Of course, the next block begins whenever you begin the next trial. Somewhere, you must be starting the next trial; you could add a delay using Invoke(...) or a coroutine.

jackbrookes avatar Jun 11 '22 09:06 jackbrookes