-
Notifications
You must be signed in to change notification settings - Fork 0
/
Primitives Spawner_script
55 lines (45 loc) · 1.71 KB
/
Primitives Spawner_script
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
48
49
50
51
52
53
54
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace gamee.name.primitives
{
public class EnemyManager : MonoBehaviour
{
private int randm;
private void Start()
{
InvokeRepeating("Spawner", 2, 2);
}
private void Spawner()
{
randm = Random.Range(1, 5);
switch (randm)
{
case 1:
GameObject Cub = GameObject.CreatePrimitive(PrimitiveType.Cube);
Cub.name = "Cub";
Cub.transform.position=new Vector3(Random.Range(-1, 1), 0f, Random.Range(-1, 1));
Cub.AddComponent<Cube_script>();
break;
case 2:
GameObject Sph = GameObject.CreatePrimitive(PrimitiveType.Sphere);
Sph.name = "Spher";
Sph.transform.position=new Vector3(Random.Range(-3, 3), 0f, Random.Range(-3, 3));
Sph.AddComponent<Sphere_script>();
break;
case 3:
GameObject Cyl = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
Cyl.name = "Cyl";
Cyl.transform.position=new Vector3(Random.Range(-5, 5), 0f, Random.Range(-5, 5));
Cyl.AddComponent<Cylinder_script>();
break;
case 4:
GameObject Cap = GameObject.CreatePrimitive(PrimitiveType.Capsule);
Cap.name = "Cap";
Cap.transform.position=new Vector3(Random.Range(-7, 7), 0f, Random.Range(-7, 7));
Cap.AddComponent<Capsule_script>();
break;
}
}
}
}