-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAttract_Destroy
41 lines (36 loc) · 884 Bytes
/
Attract_Destroy
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public GameObject a, b;
private attract att;
public Vector3 pos1, pos2;
public int c = 1;
// Start is called before the first frame update
void Start()
{
att = GetComponent<attract>();
}
public void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag=="Enemy")
{
Destroy(collision.gameObject);
if(c==0)
{
a = Instantiate(b, pos2, Quaternion.identity);
}
if(c==1)
{
a = Instantiate(b, pos2, Quaternion.identity);
}
att.attractedTO = a;
c++;
if(c>=2)
{
c = 0;
}
}
}
}