Speed control camera movement

void Update()
{
   float h=Input.GetAxis("Horizontal")*speed*Time.deltaTime;
   float v=Input.GetAxis("Vertical")*speed*Time.deltaTime;
   transform.Translate(h,0,v);//或者可以分开写

//transform.Translate(Vector3.right*h);
//
transform.Translate(Vector3.forward*v);
}

speed is the step size, the step size is multiplied by the time distance of each frame is

deltaTime is this frame to the next rendering pass the time.

 

Guess you like

Origin www.cnblogs.com/h694879357/p/12592042.html