//==========================
// - FileName: PlayerMove.cs
// - Created: true.
// - CreateTime: 2020/07/21 23:58:59

// - Region: China WUHAN
// - Description:
//==========================
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CubeMove : MonoBehaviour
{
public float speed = 3f;
public float forwards = 0f;

/// <summary>
/// 人物移动均在 Fixed 中进行
/// </summary>
void FixedUpdate()
{
Move();
}

private void Move()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
//按下键的时候才做行为
if (Mathf.Abs(h) > 0 || Mathf.Abs(v) > 0)
{
//运动的时候使用世界坐标进行
transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime, Space.World);
if (h != 0)
//人物朝向设置
this.transform.rotation = Quaternion.LookRotation(new Vector3(h, 0, v));
float res = Mathf.Max(Mathf.Abs(h), Mathf.Abs(v));
}
}
}