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

public class SimpleSpawner : MonoBehaviour {

    public GameObject zombiePrefab;
    public GameObject tidePodTarget;

    private GameObject zombieParent;

    private void Start()
    {
        if (zombiePrefab == null || tidePodTarget == null)
            gameObject.SetActive(false);

        zombieParent = new GameObject();
        zombieParent.name = "Zombies";
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100f, LayerMask.GetMask("World")))
            {
                GameObject z = Instantiate(zombiePrefab, hit.point + Vector3.up * 2f, Quaternion.identity, zombieParent.transform);
                z.GetComponent<KidController>().destination = tidePodTarget.transform;
            }
        }
    }
}
