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

public class Trigger : MonoBehaviour
{
    public float rotationSpeed;
    public float bobPeriod, bobAmplitude;
    Vector3 initialPosition;

    public bool isTriggered;


    public Transform player;
    public float size;

    private void Start()
    {
        initialPosition = transform.position;
    }

    private void Update()
    {
        isTriggered = (player.position - transform.position).sqrMagnitude < size;


        transform.rotation = Quaternion.Euler(-90.0f, 0, rotationSpeed * Time.time);
        transform.position = initialPosition + Vector3.up * bobAmplitude * Mathf.Sin(bobPeriod * Time.time);
    }
}
