Particles trigger starting problem
HI There,
Thanks a lot for many topics which was useful
I needed to trigger the particles to act and stop by the mouth trigger ..
i found through many atricles the " Particles trigger script "
// ParticleControlHelper with Transition!
// Version: 0.0.1
// Event: Lens Initialized
// Description: Plays Particle on trigger
// @input string particleTrigger = TouchStartEvent { "widget": "combobox", "values": [ { "label": "Brows Lowered", "value": "BrowsLoweredEvent" }, { "label": "Brows Raised", "value": "BrowsRaisedEvent" }, { "label": "Brows Returned To Normal", "value": "BrowsReturnedToNormalEvent" }, { "label": "Face Found", "value": "FaceFoundEvent" }, { "label": "Face Lost", "value": "FaceLostEvent" }, { "label": "Kiss Finished", "value": "KissFinishedEvent" }, { "label": "Kiss Started", "value": "KissStartedEvent" }, { "label": "Mouth Closed", "value": "MouthClosedEvent" }, { "label": "Mouth Opened", "value": "MouthOpenedEvent" }, { "label": "Smile Finished", "value": "SmileFinishedEvent" }, { "label": "Smile Started", "value": "SmileStartedEvent" }, { "label": "Touch Start", "value": "TouchStartEvent" }, { "label": "Touch End", "value": "TouchEndEvent" }, { "label": "Tap", "value": "TapEvent" } ] }
//@ui {"widget":"separator"}
// @input bool stoppable = false
// @input string particleStopper = TouchEndEvent { "widget": "combobox", "values": [ { "label": "Brows Lowered", "value": "BrowsLoweredEvent" }, { "label": "Brows Raised", "value": "BrowsRaisedEvent" }, { "label": "Brows Returned To Normal", "value": "BrowsReturnedToNormalEvent" }, { "label": "Face Found", "value": "FaceFoundEvent" }, { "label": "Face Lost", "value": "FaceLostEvent" }, { "label": "Kiss Finished", "value": "KissFinishedEvent" }, { "label": "Kiss Started", "value": "KissStartedEvent" }, { "label": "Mouth Closed", "value": "MouthClosedEvent" }, { "label": "Mouth Opened", "value": "MouthOpenedEvent" }, { "label": "Smile Finished", "value": "SmileFinishedEvent" }, { "label": "Smile Started", "value": "SmileStartedEvent" }, { "label": "Touch Start", "value": "TouchStartEvent" }, { "label": "Touch End", "value": "TouchEndEvent" }, { "label": "Tap", "value": "TapEvent" }], "showIf":"stoppable" }
// Get the Particle's Mesh Visual
var meshVis = script.getSceneObject().getFirstComponent("Component.MeshVisual");
// Variable to store what time particle started
var startTime;
var transitionState = 0; // 0 none, 1 transition in, 2 particle showing, 3 transition out
var transitionSpeed = 60;
var spawnMaxParticles = meshVis.mainPass.spawnMaxParticles;
// Update the particle time every frame when needed
function update()
{
if (startTime)
{
// Calculate how many seconds have elapsed since we've triggered partcles
var particleTime = getTime() - startTime;
// Pass it in to our Particle Material
meshVis.mainPass.externalTimeInput = particleTime;
if (transitionState == 1) {
meshVis.mainPass.spawnMaxParticles += transitionSpeed;
if (meshVis.mainPass.spawnMaxParticles >= spawnMaxParticles) {
transitionState = 2
}
} else if (transitionState == 3) {
meshVis.mainPass.spawnMaxParticles -= transitionSpeed;
if(meshVis.mainPass.spawnMaxParticles <= 0) {
stopParticle();
}
}
}
}
var updateEvent = script.createEvent("UpdateEvent");
updateEvent.bind(update);
// On an event, store the time when particle is triggered
function startParticle()
{
startTime = getTime();
meshVis.mainPass.spawnMaxParticles = 0;
transitionState = 1;
}
var particleTriggerEvent = script.createEvent(script.particleTrigger);
particleTriggerEvent.bind(startParticle);
if (script.stoppable) {
// On an event, store the time when particle is triggered
function stopParticle()
{
transitionState = 0;
startTime = 0;
meshVis.mainPass.externalTimeInput = 0;
}
function startTransitionOutParticle() {
transitionState = 3;
}
var particleStopEvent = script.createEvent(script.particleStopper);
particleStopEvent.bind(startTransitionOutParticle);
}
It is working fine BUT as the lens turns on, the particles appear at the mouth as a static shape , and as the user opens his mouth the script works fine !
any solution ?

here the mouth is not opened yet
Thanks in advance for any help
also i want to know if its possible to make the particles aim towards a fixed point or object on the screen