Created
April 9, 2020 02:01
-
-
Save JayStGelais/bdb9d94223d823508f3e7492f13f12b2 to your computer and use it in GitHub Desktop.
Load a Tiled map and assign Collider2D to CinemachineConfiner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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