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

public class BallCup : MonoBehaviour
{
    [SerializeField]
    private GameObject flag;
    private Vector3 targetpos;
    // Start is called before the first frame update
    void Start()
    {
        targetpos = new Vector3(flag.transform.position.x,flag.transform.position.y+3,flag.transform.position.z);
    }

    // Update is called once per frame
    void Update()
    {
        //ballオブジェクトとの距離を計算
        GameObject ball = GameObject.FindWithTag("Ball");
        float distance = Vector3.Distance(ball.transform.position,this.transform.position);
        if(distance < 30.0f){
            //flag.transform.position = Vector3.Lerp(flag.transform.position,targetpos,Time.deltaTime);
        }
    }
    private void OnTriggerEnter(Collider collision){
        Debug.Log("cup in");
        if(collision.gameObject.tag == "Ball"){
            Debug.Log("cup in");
        }
    }
}
