헤엄치는 고래별, 움직이는 해산물

This commit is contained in:
HIHIHIHIHIHIzz
2026-06-22 16:22:10 +09:00
parent f443c4a4de
commit d12a45ad29
46 changed files with 4280 additions and 6 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;
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fb034270e545f1f42be49ca0557e2c46