forked from vaibhav899050/PastClones-IGDC-GameDev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spwan.cs
102 lines (75 loc) · 2.01 KB
/
spwan.cs
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class spwan : MonoBehaviour
{
// Start is called before the first frame update
public GameObject source;
public GameObject cloneprefab;
public float delay = 0.01f;
public float timeer = 3f;
private float nextActionTime = 0.0f;
public float period = 10f;
public Vector2 spawnpoint1;
int i = 0;
bool starttime;
public GameObject currentclone;
CapsuleCollider2D capsule;
CapsuleCollider2D capsule1;
float timer;
public int cloneid1 = 0;
void Start()
{
//spawnpoint1 = new Vector2(-0.05f, -0.01f);
}
// Update is called once per frame
void Update()
{
if (i <=3 && Input.GetKeyDown(KeyCode.K))
{
//timer += Time.deltaTime;
//starttime = true;
//starttime = false;
i++;
spwanobj();
cloneid1 = i;
timer = 0;
/*if (Time.time > nextActionTime)
{
nextActionTime += period;
spwanobj();
i++;
cloneid1 = i;
//i++;
}*/
}
if (starttime)
{
timer += Time.deltaTime;
}
if (timer > delay)
{
//nextActionTime += period;
}
//Debug.Log(i);
}
void spwanobj()
{
//Vector2 v = new Vector2(-6.78f, -3.5f);
if (i == 1)
{
Vector2 v = new Vector2(-6.78f, -3.5f);
Instantiate(cloneprefab, v, source.transform.rotation);
}
if (i == 2)
{
Vector2 v = new Vector2(-7.65f, -3.5f) ;
Instantiate(cloneprefab, v, source.transform.rotation);
}
if (i == 3)
{
Vector2 v = new Vector2(-8.77f, -3.5f);
Instantiate(cloneprefab, v, source.transform.rotation);
}
}
}