You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
681 B
17 lines
681 B
3 years ago
|
using UnityEngine;
|
||
|
|
||
|
public class BulletScript : MonoBehaviour {
|
||
|
|
||
|
// collision check. If the projectile collides with a wall or with its own tank, then it is simply destroyed.
|
||
|
// If the projectile collides with an enemy tank, then it is destroyed and calls the method of reducing HP in the GameScene script.
|
||
|
private void OnCollisionEnter2D(Collision2D collision) {
|
||
|
if (collision.gameObject.name == "LeftBorder" || collision.gameObject.name == "RightBorder" || collision.gameObject.name == "PlayerTank") {
|
||
|
Destroy(gameObject);
|
||
|
}
|
||
|
else {
|
||
|
GameScene.instance.HitByEnemy();
|
||
|
Destroy(gameObject);
|
||
|
}
|
||
|
}
|
||
|
}
|