Skip to content

Instantly share code, notes, and snippets.

@JayStGelais
JayStGelais / LoadIledMpa.cs
Created April 9, 2020 02:01
Load a Tiled map and assign Collider2D to CinemachineConfiner
private void LoadMap(GameObject mapPrefab, string playerSpawnPoint)
{
// map is of type Gameobject
map = Instantiate(mapPrefab, this.transform);
cinemachineConfiner.m_BoundingShape2D = map.gameObject.GetComponent<Collider2D>();
cinemachineConfiner.InvalidatePathCache();
var spawnPointTranform = GetComponentsInChildren<SpawnPoint>()
.First(item => item.gameObject.name == playerSpawnPoint)
.transform;
@JayStGelais
JayStGelais / DefaultTmxImporter.cs
Last active April 9, 2020 01:56
Automatically generate Collider2D around boundary of Tiled Map
public class DefaultTmxImporter : CustomTmxImporter
{
public override void TmxAssetImported(TmxAssetImportedArgs args)
{
var map = args.ImportedSuperMap;
CreateColliderForCameraConfiner(map);
}
private static void CreateColliderForCameraConfiner(SuperMap map)
{