플레이어 컨트롤러 추가 및 이동 및 회전 기능 구현중
This commit is contained in:
54
Assets/Scripts/PlayerController.cs
Normal file
54
Assets/Scripts/PlayerController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user