This commit is contained in:
2026-06-24 17:43:37 +09:00
parent 24f5f729e4
commit 122d59b0f5
2297 changed files with 517608 additions and 605 deletions

View File

@@ -0,0 +1,51 @@
using UnityEngine;
public class SeaCreatureWaypoint : MonoBehaviour
{
[Header("Waypoint Settings")]
public Transform[] waypoints;
[Header("Movement Settings")]
public float moveSpeed = 2f;
public float rotationSpeed = 5f;
public float arriveDistance = 0.2f;
private int currentWaypoint = 0;
void Update()
{
if (waypoints == null || waypoints.Length == 0)
return;
Transform target = waypoints[currentWaypoint];
// 이동
transform.position = Vector3.MoveTowards(
transform.position,
target.position,
moveSpeed * Time.deltaTime);
// 바라보는 방향
Vector3 direction = target.position - transform.position;
if (direction != Vector3.zero)
{
Quaternion targetRotation = Quaternion.LookRotation(direction);
transform.rotation = Quaternion.Slerp(
transform.rotation,
targetRotation,
rotationSpeed * Time.deltaTime);
}
// 도착하면 다음 웨이포인트
if (Vector3.Distance(transform.position, target.position) < arriveDistance)
{
currentWaypoint++;
if (currentWaypoint >= waypoints.Length)
{
currentWaypoint = 0;
}
}
}
}