Why particle lights over my Sprite with shader "Sprite/Diffuse"

I am facing a problem when my character is close to a particle system with dynamic lights. The lights go beyond the sprite set with the shader (Sprite / Diffuse):

!(http://

I have tried to adjust the z-axis of the objects, but if I put the character away from the light the image does not receive light effects. (POINT LIGHT)

Here’s a video to better illustrate the scenario:

I’m new to the particles and lights, what am I doing wrong?

Thanks in advanced!)

Maybe you would have better control over the light if you didn’t use the particles to control intensity and position.
If you can make it work with a single light instead, make a simple range and intensity script that controls the fire flaring.
This will probably be better for performance as well, as particles can make multiple lights per system.

Hi @Egil

Thanks for the answer.

“particles can make multiple lights per system.” Does the particle system create a light for each particle?

It can, you can limit the amount of lights used in the “Maximum Lights”. Might be hard to notice, since in the quality setting the pixel light count is set low by default.

Testing it with many particle lights and a high pixel light count, batches(draw calls) increases.

Made a little script for fun, maybe it could be a useful starting point for you.

using UnityEngine;
public class LightController : MonoBehaviour {
    public AnimationCurve lightIntensity;
    public float lightIntensityMultiplier = 1;
    public float lightIntensitySpeed = 1;
    public AnimationCurve lightRange;
    public float lightRangeMultiplier = 1;
    public float lightRangeSpeed = 1;
    public Gradient lightColor;
    public float lightColorSpeed = 1;
    Light aLight;

    void Start () {
        aLight = GetComponent<Light>();
        lightIntensity.postWrapMode = WrapMode.Loop;
        lightRange.postWrapMode = WrapMode.Loop;
    }

    void Update () {
        AnimateLight();
    }

    void AnimateLight() {
        aLight.intensity = lightIntensity.Evaluate(Time.time * lightIntensitySpeed) * lightIntensityMultiplier;
        aLight.range = lightRange.Evaluate(Time.time * lightRangeSpeed) * lightRangeMultiplier;
        aLight.color = lightColor.Evaluate((Time.time * lightColorSpeed)%1);
    }
}
1 Like

This is great! I’ll try to implement this!