-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPeople_spawner.cs
More file actions
53 lines (38 loc) · 1.29 KB
/
People_spawner.cs
File metadata and controls
53 lines (38 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//This script creates clones of a public gameobject that you provide it with healthy and infected versions. This way. your game
//can detect which instantiated people are infected or sick. If you want to mix in variance in mask usage, you could
//also add that here.
public class People_spawner : MonoBehaviour
{
public CalculateInfected calculateInfected;
public GameObject PeopleToSpawn;
public Vector3 position;
private int totalInfected;
private int totalHealthy;
// Start is called before the first frame update
void Start()
{
totalInfected = CalculateInfected.TotalInfected;
totalHealthy = CalculateInfected.TotalHealthy;
for (int i = 0; i < totalInfected; i++)
{
CreateInfectedPerson();
}
for (int i = 0; i < totalHealthy; i++)
{
CreateHealthyPerson();
}
}
void CreateInfectedPerson()
{
GameObject clone = Instantiate(PeopleToSpawn, position, Quaternion.identity);
clone.name = "Infected";
}
void CreateHealthyPerson()
{
GameObject clone = Instantiate(PeopleToSpawn, position, Quaternion.identity);
clone.name = "Healthy";
}
}