카메라 설정 변경

45도 y:18 z:-18 로 설정
z축만 follow하는 컨트롤러도 사용해봤으나 별로여서 코드만 남겨둠.
This commit is contained in:
2026-02-01 14:36:02 +09:00
parent 4e852b9da6
commit 7927dab72f
5 changed files with 154 additions and 101 deletions

View File

@@ -0,0 +1,49 @@
using UnityEngine;
public class SimpleCameraZFollow : MonoBehaviour
{
[Header("Camera Settings")]
[SerializeField] private float fixedXPosition = 0f;
[SerializeField] private float fixedYPosition = 10f;
[SerializeField] private float zOffset = -10f;
[SerializeField] private float smoothSpeed = 5f;
[SerializeField] private bool lockRotation = true;
private Transform target;
private void Start()
{
FindPlayerTarget();
}
private void FindPlayerTarget()
{
var players = FindObjectsByType<NetworkPlayerController>(FindObjectsSortMode.None);
foreach (var player in players)
{
if (player.IsOwner)
{
target = player.transform;
Debug.Log($"<color=green>[Camera] Target found: {player.name}</color>");
return;
}
}
Invoke(nameof(FindPlayerTarget), 0.5f);
}
private void LateUpdate()
{
if (target == null) return;
Vector3 targetPos = target.position;
Vector3 desiredPosition = new Vector3(fixedXPosition, fixedYPosition, targetPos.z + zOffset);
transform.position = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed * Time.deltaTime);
if (!lockRotation)
{
transform.LookAt(target);
}
}
}

View File

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