From 9d5354c1cff36ad730b16912d45405bc532a6297 Mon Sep 17 00:00:00 2001 From: JoshuaReason Date: Sat, 26 Jan 2019 23:55:27 +1100 Subject: [PATCH] Fixed model duplication --- Assets/Scipts/Map.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Assets/Scipts/Map.cs b/Assets/Scipts/Map.cs index fc99079..9e49f62 100644 --- a/Assets/Scipts/Map.cs +++ b/Assets/Scipts/Map.cs @@ -45,13 +45,14 @@ public class Map : MonoBehaviour Player PS = Player.GetComponent(); Transform PT = Player.transform; Transform model = PT.Find("Model"); - PS.dummies.Add(Instantiate(model, new Vector3(PT.position.x -TileSize * MapDimensions.x, PT.position.y, PT.position.z), transform.rotation, model).gameObject); - PS.dummies.Add(Instantiate(model, new Vector3(PT.position.x + TileSize * MapDimensions.x, PT.position.y, PT.position.z), transform.rotation, model).gameObject); - PS.dummies.Add(Instantiate(model, new Vector3(PT.position.x, PT.position.y, PT.position.z - TileSize * MapDimensions.y), transform.rotation, model).gameObject); - PS.dummies.Add(Instantiate(model, new Vector3(PT.position.x, PT.position.y, PT.position.z + TileSize * MapDimensions.y), transform.rotation, model).gameObject); + PS.dummies.Add(Instantiate(model, new Vector3(PT.position.x -TileSize * MapDimensions.x, PT.position.y, PT.position.z), transform.rotation, PT).gameObject); + PS.dummies.Add(Instantiate(model, new Vector3(PT.position.x + TileSize * MapDimensions.x, PT.position.y, PT.position.z), transform.rotation, PT).gameObject); + PS.dummies.Add(Instantiate(model, new Vector3(PT.position.x, PT.position.y, PT.position.z - TileSize * MapDimensions.y), transform.rotation, PT).gameObject); + PS.dummies.Add(Instantiate(model, new Vector3(PT.position.x, PT.position.y, PT.position.z + TileSize * MapDimensions.y), transform.rotation, PT).gameObject); foreach (GameObject dummie in PS.dummies) { + dummie.transform.parent = model; foreach (Collider col in dummie.GetComponentsInChildren()) { col.enabled = false;