0
\$\begingroup\$

I've an explosion effect using particle system.

Explosion occur on air, so I want to add a "flash" light effect when explosion occur (that light sky and terrain ).

Can you suggest me best way to obtain ?

Thanks

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Presumably you tried adding a point light and adjusting its brightness along an animation curve? Or adding a sub-system with a lights module? How did these attempts work out for you so far? What concretely did you try, and where did you run into an obstacle you need help overcoming? \$\endgroup\$ – DMGregory Aug 17 '19 at 19:41
  • \$\begingroup\$ Exactly: finally i've added a point light and a routine that increment (and decrement) intensity and range. And yes.. I can say result is good. \$\endgroup\$ – stighy Aug 18 '19 at 18:18
  • 1
    \$\begingroup\$ If you've solved your problem, please post your solution as an answer that can help other developers. :) \$\endgroup\$ – DMGregory Aug 18 '19 at 18:19
0
\$\begingroup\$

I've just added a point light with a script that increase (then decrease) :

  • intensity

  • range

in a fixed span time .

This is my script:

public class gsFlashLightExplosion : MonoBehaviour

{ [SerializeField] int LightStartRange;

[SerializeField] int LightEndRange;

[SerializeField] float LightStartIntensity;

[SerializeField] float LightEndIntensity;

[SerializeField] float Speed;

private bool blnRun=true;

private Light light;

// Start is called before the first frame update
void Start()
{
    light=GetComponent<Light>();
    light.range = LightStartRange;
    light.intensity = LightStartIntensity;
}

// Update is called once per frame
void Update()
{

    if(LightEndRange>light.range)
        light.range = (int)(light.range + (light.range * Speed / 100));
    else
        light.range = (int)(light.range - (light.range * Speed / 100));

    if (LightEndIntensity > light.intensity)
        light.intensity = light.intensity + (light.intensity * Speed / 100);
    else
        light.intensity = light.intensity - (light.intensity * Speed / 100);


}

}

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.