using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ball_move : MonoBehaviour
{
// Start is called before the first frame update
public float speed = 10;
private void Update()
{
float v = Input.GetAxis("Vertical");//键盘左右控制检测
float h = Input.GetAxis("Horizontal");//键盘上下控制检测
transform.Translate(h * speed * Time.deltaTime,0, v * speed * Time.deltaTime);
//这是前后左右控制,如果只想要左右或者前后可以删掉 float v = Input.GetAxis("Vertical");或者 float h = Input.GetAxis("Horizontal");
//或者也可以改动transform.Translate括号中的内容顺序
}
}