void AddThings() { thingParent = new GameObject("thingParent").transform; thingParent.parent = mapParent; foreach (THINGS thing in openedMap.things) { //Multiplayer only thing if (((thing.thingOptions & 0x10) >> 4) == 1) { continue; } float Zpos = 0; RaycastHit hit; //getting the Z(Y) height if (Physics.Raycast(new Vector3(thing.xPos, 5000, thing.yPos), Vector3.down, out hit, 10000, 1)) { Zpos = hit.point.y + 1; } Vector3 pos = new Vector3(thing.xPos, Zpos, thing.yPos); GameObject newThing = new GameObject(thing.thingType.ToString()); newThing.transform.parent = thingParent; newThing.transform.position = pos; if (MonsterType.ContainsKey(thing.thingType))//If its a monster { //Only spawn the monster if it is supposed to be on the current skill level if (skill == 0 || skill == 1) { if ((thing.thingOptions & 0x01) != 1) { continue; } else if (skill == 2) { if ((thing.thingOptions & 0x02) != 1) { continue; } else if (skill == 3 || skill == 4) { if ((thing.thingOptions & 0x04) != 1) { continue; } } } } newThing.AddComponent(MonsterType[thing.thingType]); newThing.AddComponent <Rigidbody>(); ThingController controller = newThing.AddComponent <ThingController>(); controller.OnCreate(reader.newWad.sprites, thing, reader.newWad.sounds); newThing.layer = 10; } else if (DecorationType.ContainsKey(thing.thingType))//if its a Decoration { newThing.AddComponent(DecorationType[thing.thingType]); ThingController controller = newThing.AddComponent <ThingController>(); controller.OnCreate(reader.newWad.sprites, thing, reader.newWad.sounds); } else if (PickupType.ContainsKey(thing.thingType))//if its a Pickup { newThing.AddComponent(PickupType[thing.thingType]); PickupController controller = newThing.AddComponent <PickupController>(); controller.OnCreate(reader.newWad.sprites, thing, reader.newWad.sounds); } else if (thing.thingType == 1)//player 1 { player.transform.position = pos; } } }