- Home /
How do I link/animate a light with a shuriken particle system?
Hello,
I've been trying to find a way to link a light to a shuriken particle system. It's going to be used for the light flash of an explosion and muzzle flashes and the like. Could you elaborate how I would be able to animate such a thing? I'm guessing with code or something, but maybe with the animation view. I couldn't figure it out. could anyone help me? (the effects will be pre-fabs spawned in at the correct location)
Thanks!
Answer by Owen-Reynolds · Oct 25, 2012 at 11:20 PM
Could just put a disabled spot/point light on the end of your gun. Then just turn it on and off when you shoot:
public GameObject myLight; // drag in the light
void shoot() {
myLight.active=true;
// spawn particles for flash, etc...
}
Then use a counter, or Time or a coroutine to set active=false after 2 frames (the same way you wait 1/2-sec to fire, also wait 1/20th sec to turn off the light.)
Answer by Kratilim · Oct 27, 2012 at 02:58 PM
Thanks, I asked a programmer to help me with a bit of code to control the light with a lerp.
Lerp might be good for turning a light off -- dies down fast, then slowly fades the last little bit. For On, either a $$anonymous$$oveTowards or even something as simple as `if(intensity<6) intensity++;` might look nicer. Lerp is just one way out of many ways to make a number change.