플레이어 컨트롤러 추가 및 이동 및 회전 기능 구현중

This commit is contained in:
2026-01-20 02:31:22 +09:00
parent accf9c1287
commit de039d4ffb
6 changed files with 168 additions and 154 deletions

View File

@@ -0,0 +1,54 @@
using System.Numerics;
using TreeEditor;
using UnityEngine;
using Quaternion = UnityEngine.Quaternion;
using Vector3 = UnityEngine.Vector3;
public class PlayerController : MonoBehaviour
{
[SerializeField]
float _speed = 10.0f;
void Start()
{
}
float _yAngle = 0.0f;
void Update()
{
_yAngle += Time.deltaTime * 100.0f;
// 절대 회전값 지정해서 회전
// transform.eulerAngles = new Vector3(0.0f, _yAngle, 0.0f);
// +- delta 값을 특정 축으로 회전
// transform.Rotate(new Vector3(0.0f, Time.deltaTime * 100.0f, 0.0f));
// transform.rotation = Quaternion.Euler(new Vector3(0.0f, _yAngle, 0.0f));
if (Input.GetKey(KeyCode.W))
{
transform.rotation = Quaternion.LookRotation(Vector3.forward);
// transform.Translate(Vector3.forward * Time.deltaTime * _speed);
}
if (Input.GetKey(KeyCode.S))
{
transform.rotation = Quaternion.LookRotation(Vector3.back);
// transform.Translate(Vector3.back * Time.deltaTime * _speed);
}
if (Input.GetKey(KeyCode.A))
{
transform.rotation = Quaternion.LookRotation(Vector3.left);
// transform.Translate(Vector3.left * Time.deltaTime * _speed);
}
if (Input.GetKey(KeyCode.D))
{
transform.rotation = Quaternion.LookRotation(Vector3.right);
// transform.Translate(Vector3.right * Time.deltaTime * _speed);
}
}
}