Added explosion on enemy defeat
Also added a little force for when you land on an enemy, but sometimes it YEETS the player if done at the right moment with a trumpet jump
This commit is contained in:
@@ -69,6 +69,14 @@ public class EnemyPatrol : MonoBehaviour {
|
||||
}
|
||||
|
||||
public void DefeatEnemy() {
|
||||
StartCoroutine(Defeat());
|
||||
}
|
||||
|
||||
IEnumerator Defeat() {
|
||||
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
|
||||
animator.Play("Explosion");
|
||||
yield return new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length);
|
||||
this.gameObject.GetComponent<BoxCollider2D>().enabled = true;
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +179,7 @@ public class PlayerBehavior : MonoBehaviour
|
||||
void OnCollisionEnter2D(Collision2D collision) {
|
||||
if (collision.gameObject.tag == "Enemy") {
|
||||
if (collision.transform.position.y < transform.position.y) {
|
||||
_rb.AddForce(Vector2.up * 8, ForceMode2D.Impulse);
|
||||
collision.gameObject.GetComponent<EnemyPatrol>().DefeatEnemy();
|
||||
} else {
|
||||
DestroyPlayer();
|
||||
|
||||
Reference in New Issue
Block a user