using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Egg_script : MonoBehaviour
{
    private Rigidbody rb;
    public GameObject penguin;
    private Animator animator;
	public GameObject particle;

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    void OnTriggerEnter2D(Collider2D other) {
        if (other.CompareTag("Penguin")) {
            StartCoroutine(Hatch(other));
            animator.SetBool("Hatching", true);
			particle.SetActive(true);
			
        }
    }

    IEnumerator Hatch(Collider2D other) {
        yield return new WaitForSeconds(1);
        Instantiate(other, transform.position, Quaternion.identity);
        Destroy(gameObject);
    }

}
