球体移动瞬移
游戏运行时按W,A,S,D键进行移动。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Manager : MonoBehaviour
{
public GameObject cubeObj;
public float speed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
cubeObj.transform.Translate(new Vector3(h, v, 0) * Time.deltaTime * speed);
if(Input.GetKey(KeyCode.Space))
{
cubeObj.transform.position = new Vector3(0, 0, 0);
}
}
}



