ReplayPuzzleGame/Assets/Resources/Scripts/Prop/CheeseEnter.cs
qoralstmd6825 ebabe72e56 버그 픽스
애니메이션 스프라이트 이상하게 나오는 부분 수정, 물에 빠졌을때 3초간 리플레이 기능 사용 가능하게 변경
2026-02-25 16:02:21 +09:00

40 lines
1.0 KiB
C#

using Unity.Mathematics.Geometry;
using UnityEngine;
using UnityEngine.InputSystem;
public class GoalTrigger : MonoBehaviour
{
private bool isTriggered = false;
private Vector3 _startPos;
[SerializeField] private float bobHeight = 0.3f;
[SerializeField] private float bobSpeed = 2.5f;
private void Start()
{
_startPos = transform.position;
}
private void Update()
{
if (!isTriggered)
{
float newY = _startPos.y + ((Mathf.Sin(Time.time * bobSpeed) + 1f) * 0.5f) * bobHeight;
transform.position = new Vector3(_startPos.x, newY, _startPos.z);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
if (!isTriggered)
{
isTriggered = true;
CameraEffect cam = Camera.main.GetComponent<CameraEffect>();
cam.ZoomUpPlayer(1.5f, 0.5f);
GameManager.instance.ClearLevel();
}
}
}
}