using System;
using UnityEngine;

public class Pan : MonoBehaviour
{
    [SerializeField] private PanController controller;
    [SerializeField] private float thrust;
    [SerializeField] private float deadZone = 0.1f;

    private void OnTriggerStay2D(Collider2D other)
    {
        // 移動量が少ないときは動かない
        if (controller.Velocity.magnitude < deadZone)
        {
            return;
        }
        // コーンの壁抜けを抑制
        if (controller.Velocity.magnitude >= 200f)
        {
            return;
        }
        other.attachedRigidbody.AddForce(controller.Velocity * thrust, ForceMode2D.Impulse);
    }
}