-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeteorTarget.cs
More file actions
50 lines (45 loc) · 1.53 KB
/
Copy pathMeteorTarget.cs
File metadata and controls
50 lines (45 loc) · 1.53 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
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeteorTarget : MonoBehaviour
{
public float timeTillDestroyed;
public GameObject explosionPrefab;
public Vector3 overrideRand;
// Start is called before the first frame update
void Start()
{
if(explosionPrefab==null)
{
explosionPrefab = GameManager.GM.genericMeteorCollPF;
}
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter(Collider collision)
{
if (collision.transform.CompareTag("Meteor"))
{
if (collision.GetComponent<MeteorMoveTowards>().myTarget == this) //some meateors were destroying other targets cause of the randomized angle.
{
GameManager.GM.PlayClip(GameManager.GM.meteorExplode);
//leave a crator and definitely destroy me:
Instantiate(explosionPrefab, transform.position, Quaternion.identity);
Destroy(collision.gameObject);
Destroy(gameObject);
}
}
}
//private void OnCollisionEnter(Collision collision)
//{
// if(collision.transform.CompareTag("Meteor"))
// {
// //leave a crator and definitely destroy me:
// Instantiate(explosionPrefab, transform.position, Quaternion.identity);
// Destroy(collision.gameObject);
// Destroy(gameObject);
// }
//}
}