using UnityEngine;

namespace Nan.Scripts
{
    public class EnemyBullet : MonoBehaviour
    {
        public Vector2 Velocity { get; set; }

        private void Start()
        {
            print("Enemy Bullet Instantiated");
            Destroy(gameObject, 1.0f);

        }

        private void Update()
        {
            GetComponent<Rigidbody2D>().velocity = Velocity;
            transform.rotation = Quaternion.AngleAxis(Mathf.Atan2(-Velocity.x, Velocity.y) * Mathf.Rad2Deg,
                Vector3.forward);
        }

        private void OnCollisionEnter2D(Collision2D other)
        {
            Destroy(gameObject);
        }
    }
}