using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
public float speed = 3;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
//获取键盘A、D或者←、→按钮事件,发生水平方向的移动(获取值为float)
float v = Input.GetAxis("Vertical");
transform.Translate(new Vector3(h, v, 0)*Time.deltaTime*speed);
//当前脚本所在的组件移动xz yz 为变量 Time.deltaTime 1米每秒的速度
}
}