horizontal = Input.GetAxis("Horizontal");
if (horizontal < 0.1&&horizontal>-0.1)
horizontal = 0;
vertical = Input.GetAxis("Vertical");
if (vertical < 0.1&& vertical> -0.1)
vertical = 0;
//tran是物体的transform game1是摄像机的gameObject
if (horizontal != 0 || vertical != 0)
{
Vector3 targetDirection = new Vector3(horizontal, 0, vertical);
float y = game1.transform.rotation.eulerAngles.y;
targetDirection = Quaternion.Euler(0, y, 0) * targetDirection;
game1.transform.Translate(targetDirection * Time.deltaTime * movespeed, Space.World);
tran.Translate(targetDirection * Time.deltaTime * movespeed, Space.World);
}