Particles on Kiss Event not working
Hello!
I'm trying to start a particle effect on Kiss started and stop it on Kiss finished. My script works just as expected when I use any other event (ei mouth opened or on tap), but when I use kiss started, the particle stops after 2 seconds even if I haven't moved. If I change it to Mouth Opened or any other event besides Kiss, it works perfectly; the particle effect loops forever until I close my mouth which is what I want.
This is my script:
// -----JS CODE-----
// What event to trigger particle on
//var triggerEventName = "KissStartedEvent";
// Get the Particle's Mesh Visual
var meshVis = script.getSceneObject().getFirstComponent("Component.MeshVisual");
// Variable to store what time particle started
var startTime;
// Update the particle time every frame when needed
function update()
{
if (startTime)
{
// Calculate how many seconds have elapsed since we've triggered particles
var particleTime = getTime() - startTime;
// Pass it in to our Particle Material
meshVis.mainPass.externalTimeInput = particleTime;
}
}
var updateEvent = script.createEvent("UpdateEvent");
updateEvent.bind(update);
// On an event, store the time when particle is triggered
function startParticle()
{
startTime = getTime();
}
var particleTriggerEvent = script.createEvent("KissStartedEvent");
particleTriggerEvent.bind(startParticle);
// What event to stop particle on
//var stopEventName = "KissFinishedEvent";
// On an event, stop particle by setting particle time to 0
function stopParticle()
{
startTime = 0;
meshVis.mainPass.externalTimeInput = 0;
}
var particleStopEvent = script.createEvent("KissFinishedEvent");
particleStopEvent.bind(stopParticle);
I tried using the behavior script as well, enabling and disabling the particles on kiss started and finished. It "works" but the particles don't loop and stop after 4 seconds even if the kiss hasn't ended.
Hi Abigail,
Unfortunately there are currently some issues with the Kiss Started and Finished events. The Finished event will automatically be triggered if a kiss is held for longer than a few seconds, and when this happens the Started event will be more difficult to trigger for a few seconds. We are working on improving this in the future. Sorry for the inconvenience!
Jacob
Yryff