2019.10.23
第一次简书文章,记U3D作业
关于方块移动:
void Update()
{
Contromove();
}
public void Contromove()
{
Tranlate(KeyCode.D, new Vector3(2, 0, 0));
Tranlate(KeyCode.A, new Vector3(-2, 0, 0));
Tranlate(KeyCode.W, new Vector3(0, 0, 2));
Tranlate(KeyCode.S, new Vector3(0, 0, -2));
}
public void Tranlate(KeyCode key,Vector3 v)
{
if (Input.GetKey(key))
{
gameObject.transform.Translate(v * Time.deltaTime);
}
}