멀티플레이어 카메라 대응

카메라 각도 변경
This commit is contained in:
2026-01-17 00:19:04 +09:00
parent 1ba1d2c03c
commit b6822691b6
2 changed files with 15 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ using UnityEngine;
using UnityEngine.InputSystem;
using Unity.Netcode;
using Unity.Netcode.Components;
using Unity.Cinemachine;
[RequireComponent(typeof(NetworkObject))]
public class PlayerNetworkController : NetworkBehaviour
@@ -40,6 +41,18 @@ public class PlayerNetworkController : NetworkBehaviour
{
if (!IsOwner) return;
// 1. 씬에 있는 가상 카메라를 찾습니다.
// Unity 6에서는 CinemachineVirtualCamera 대신 CinemachineCamera를 주로 사용합니다.
var vcam = GameObject.FindAnyObjectByType<CinemachineCamera>();
if (vcam != null)
{
// 2. 카메라의 Follow와 LookAt 대상을 '나'로 설정합니다.
vcam.Follow = transform;
vcam.LookAt = transform;
Debug.Log("<color=green>[Camera] 로컬 플레이어에게 카메라가 연결되었습니다.</color>");
}
_inputActions = new PlayerInputActions();
_inputActions.Player.Jump.performed += ctx => OnJump();
_inputActions.Player.Attack.performed += ctx => OnAttackServerRpc();