using UnityEngine;
using System.Collections;

public class AddRiver : MonoBehaviour {

    public GameObject River;
    public bool front;

    void OnTriggerEnter(Collider other)
    {
        if (!front)
        {
            Instantiate(River, new Vector3(gameObject.GetComponentInParent<Transform>().position.x, gameObject.GetComponentInParent<Transform>().position.y, gameObject.GetComponentInParent<Transform>().position.z - 500), Quaternion.identity);
        }
        else
        {
            Instantiate(River, new Vector3(gameObject.GetComponentInParent<Transform>().position.x, gameObject.GetComponentInParent<Transform>().position.y, gameObject.GetComponentInParent<Transform>().position.z + 500), Quaternion.identity);
        }
        
        Destroy(gameObject);
    }
}
