Browse Source

Fixed model duplication

master
JoshuaReason 5 years ago
parent
commit
9d5354c1cf
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      Assets/Scipts/Map.cs

+ 5
- 4
Assets/Scipts/Map.cs View File

@ -45,13 +45,14 @@ public class Map : MonoBehaviour
Player PS = Player.GetComponent<Player>(); Player PS = Player.GetComponent<Player>();
Transform PT = Player.transform; Transform PT = Player.transform;
Transform model = PT.Find("Model"); 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) foreach (GameObject dummie in PS.dummies)
{ {
dummie.transform.parent = model;
foreach (Collider col in dummie.GetComponentsInChildren<Collider>()) foreach (Collider col in dummie.GetComponentsInChildren<Collider>())
{ {
col.enabled = false; col.enabled = false;

Loading…
Cancel
Save