Skip to content

Instantly share code, notes, and snippets.

@JayStGelais
Created April 9, 2020 02:01
Show Gist options
  • Select an option

  • Save JayStGelais/bdb9d94223d823508f3e7492f13f12b2 to your computer and use it in GitHub Desktop.

Select an option

Save JayStGelais/bdb9d94223d823508f3e7492f13f12b2 to your computer and use it in GitHub Desktop.
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;
playerController.transform.position = spawnPointTranform.position;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment