Danro/Assets/Scripts/Animations/EnemyAnimationEvents.cs

25 lines
669 B
C#

using UnityEngine;
using RR.Game2D.Behaviour;
public class EnemyAnimationEvents : MonoBehaviour
{
public void OnDeathBegin()
{
gameObject.layer = LayerMask.NameToLayer("No Collision");
Rigidbody2D rb = GetComponent<Rigidbody2D>();
Collider2D col = GetComponent<Collider2D>();
EnemyController controller = GetComponent<EnemyController>();
if (controller) controller.enabled = false;
if (col) col.enabled = false;
if (!rb) return;
rb.linearVelocity = Vector2.zero;
rb.bodyType = RigidbodyType2D.Kinematic;
}
public void OnDeathEnd()
{
Destroy(gameObject);
}
}