using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class move : MonoBehaviour
{
public float moveSpeed = 0.05f; //角色移动速度
private float h;
private float v;
private Vector3 dir;
private void Update()
{
PlayerMove();
}
void PlayerMove()
{
h = Input.GetAxis("Horizontal");
v = Input.GetAxis("Vertical");
dir = new Vector3(h, 0, v);
transform.LookAt(transform.position + dir); //角色朝向
transform.Translate(dir * moveSpeed, Space.World); //用Tranlate方法实现移动
}
}