So I've spent a little bit of time working on dynamic lighting.
I'm using Unity +ToolKit2d and there's not a ton of info on the web around simple 2d lighting. So maybe I can help some people out by doing a write up on how I accomplished it in The Atlas King.
(If you want to see it in action check out
)
I was having a lot of issues getting the ToolKit2d Tilemaps to work with the unity based lighting so I had to go another route...
What I eventually landed on is pretty simple. All you need to do is to add a colour layer to your toolkit2d TileMap, and go around and fill in the dark parts with a dark blue tone. Then wherever you have a light you paint around it with the light colour. After that on the Sprites that you want to react to the light, all you have to do is add a simple script which sets the sprite colour to be whatever the tilemap's colour layer value is at the sprite's position. The Nice thing about this is you can sort of blend the colour layer between the dark and light values so you can slowly fade the light out.
using UnityEngine;
using System.Collections;
public class SetToTilemapColor : MonoBehaviour {
public tk2dTileMap tilemap;
private SpriteRenderer spriteRenderer;
// Use this for initialization
void Start () {
spriteRenderer = GetComponent<SpriteRenderer> ();
}
// Update is called once per frame
void Update () {
Vector2 position = transform.position;
Color color = tilemap.GetInterpolatedColorAtPosition (position);
spriteRenderer.color = color;
}
}
Anyways, hope this helps someone.