36 lines
826 B
C#
36 lines
826 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class WaveManager : MonoBehaviour
|
|
{
|
|
public static WaveManager Instance { get; private set; }
|
|
|
|
public float amplitude = 1f;
|
|
public float length = 2f;
|
|
public float speed = 1f;
|
|
public float offset = 0f;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
Instance = this;
|
|
else if (Instance != this)
|
|
{
|
|
Debug.LogWarning("인스턴스가 이미 존재합니다. 새로 생성된 인스턴스를 삭제합니다.");
|
|
Destroy(this);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
offset += Time.deltaTime * speed;
|
|
}
|
|
|
|
public float GetWaveHeight(float x)
|
|
{
|
|
return amplitude * Mathf.Sin(x / length + offset);
|
|
}
|
|
}
|