-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforce.cs
56 lines (39 loc) · 1.27 KB
/
force.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Force : MonoBehaviour
{
public GameObject Explosion_effect;
public float explosion_time = 2.00f;
public float radius = 10.00f;
public float force = 1000.00f;
public GameObject remove_walls;
public float time_for_dust = 2.00f;
Vector3 temp;
// Start is called before the first frame update
void Start()
{
temp = remove_walls.transform.localScale;
temp = new Vector3(0, 0, 0);
}
// Update is called once per frame
void Update()
{
}
public void Explode()
{
remove_walls.transform.localScale = temp;
Destroy(this.gameObject,0.5f);
GameObject ef = Instantiate(Explosion_effect, transform.position, Quaternion.identity);
Destroy(ef, explosion_time);
Collider[] nearby_colliders = Physics.OverlapSphere(transform.position, radius);
foreach (Collider nearbyObjects in nearby_colliders)
{
Rigidbody rb = nearbyObjects.GetComponent<Rigidbody>();
if (rb != null)
{
rb.AddExplosionForce(force, transform.position, radius);
}
}
}
}