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);
}
}