using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMover : MonoBehaviour
{
[SerializeField] float angularVelocity = 100f;
[SerializeField] float movingVelocity = 5f;
float horizontalAngle =0f;
float frontMove = 0f;
#if UNITY_EDITOR
// Update is called once per frame
void Update()
{
// transformを取得 座標を取得 vector3形式
Transform myTransform = this.transform;
Vector3 moveDirection;
// 1updateごとに加算する値を計算
var horizontalRotation = Input.GetAxis("Horizontal") * angularVelocity * Time.deltaTime;
var frontMove = Input.GetAxis("Vertical") * movingVelocity * Time.deltaTime;
// 座標を1updateごとに加算
horizontalAngle += horizontalRotation;
moveDirection = new Vector3(Mathf.Sin(myTransform.eulerAngles.y * Mathf.Deg2Rad),
0,
Mathf.Cos(myTransform.eulerAngles.y * Mathf.Deg2Rad)) ;
// myTransformを更新
myTransform.rotation = Quaternion.Euler(0f, horizontalAngle, 0f);
myTransform.position += moveDirection * frontMove;
}
#endif
}