We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 68c45df commit d5a0746Copy full SHA for d5a0746
Assets/Scripts/Projectile.cs
@@ -33,6 +33,11 @@ private void Awake()
33
_collider = GetComponent<BoxCollider2D>();
34
}
35
36
+ private void OnDestroy()
37
+ {
38
+ this.destroyed?.Invoke(this);
39
+ }
40
+
41
private void Update()
42
{
43
// Move the projectile in the given direction by its speed
@@ -47,9 +52,7 @@ private void CheckCollision(Collider2D other)
47
52
48
53
// The projectile is destroyed when colliding with any object other than
49
54
// a bunker or when it splats on a bunker
50
- if (bunker == null || bunker.CheckCollision(_collider, this.transform.position))
51
- {
- this.destroyed?.Invoke(this);
55
+ if (bunker == null || bunker.CheckCollision(_collider, this.transform.position)) {
56
Destroy(this.gameObject);
57
58
0 commit comments