건물 건설 모드 및 건설 인터랙션

This commit is contained in:
2026-01-12 17:21:07 +09:00
parent 87340317ab
commit c75c5bd868
25 changed files with 3747 additions and 311 deletions

View File

@@ -0,0 +1,36 @@
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float moveSpeed = 5f;
private Vector2 _moveInput;
private CharacterController _controller;
private PlayerInputActions _inputActions;
void Awake()
{
_controller = GetComponent<CharacterController>();
_inputActions = new PlayerInputActions();
// Move 액션 연결 (Vector2 타입으로 설정되어 있어야 함)
_inputActions.Player.Move.performed += ctx => _moveInput = ctx.ReadValue<Vector2>();
_inputActions.Player.Move.canceled += ctx => _moveInput = Vector2.zero;
}
void OnEnable() => _inputActions.Enable();
void OnDisable() => _inputActions.Disable();
void Update()
{
// 입력받은 방향으로 이동 계산
Vector3 move = new Vector3(_moveInput.x, 0, _moveInput.y);
_controller.Move(move * Time.deltaTime * moveSpeed);
// 이동 중일 때 바라보는 방향 전환 (선택 사항)
if (move != Vector3.zero)
{
transform.forward = move;
}
}
}