My 2D Sprite has a material, Sprite diffuse attached to it.

Now when I set up a light, it works but if I play the Game and walk, the light turns off immediately and the Player turns black.

The light is set up, Type as Point and Baking as Realtime, Distance at Z-axis is -25.

The Camera distance is at -30 on the Z-axis.

The Player is at 0 on the Z-axis.

I set the light between Camera and Player, but I also have a Camera Follows Player script, maybe it causes the problem, but I watched the Z-axis while playing and it doesn't move on the Z-axis.

I will also post Camera Script if someone can detect any problem.

    private Vector2 velocity;

  public float smoothTimeY;
  public float smoothTimeX;

  public GameObject player;

  // Use this for initialization
  void Start () 
    player = GameObject.FindGameObjectWithTag("Player");

  // Update is called once per frame
  void FixedUpdate () 
    float posX = Mathf.SmoothDamp (transform.position.x, player.transform.position.x, ref velocity.x, smoothTimeX);
    float posY = Mathf.SmoothDamp (transform.position.y, player.transform.position.y, ref velocity.y, smoothTimeX);

    transform.position = new Vector3 (posX, posY + 29, transform.position.z);

Light visible on Edit Mode

Light still visible but not lighting up the Material

  • 1
    \$\begingroup\$ How many point-lights do you have in the scene? When you have too many, Unity will pick some to switch off to keep the framerate up. You can prevent Unity from picking the wrong ones by setting Render Mode to "Important". \$\endgroup\$
    – Philipp
    Apr 4 '16 at 17:00
  • \$\begingroup\$ I just have one Point light in the Scene. \$\endgroup\$ Apr 4 '16 at 21:27

You must log in to answer this question.

Browse other questions tagged .