immersivecognition / unity-experiment-framework

UXF - Framework for creating human behaviour experiments in Unity
https://immersivecognition.github.io/unity-experiment-framework/
MIT License
214 stars 41 forks source link

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

Closed rmib200 closed 1 year ago

rmib200 commented 2 years ago

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.

jackbrookes commented 2 years ago

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
    }
}
rmib200 commented 2 years ago

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?

jackbrookes commented 2 years ago

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.