I understand the more basic version, its supposed to be a refined form of:
if ( Input.GetAxis ( “Horizontal” ) < 0 ) {
transform.Translate( -10f * Time.deltaTime, 0, 0);
if ( Input.GetAxis ( “Horizontal” ) > 0 )
transform.Translate( 10f * Time.deltaTime, 0, 0);
So 0,0 is y and z of course. What would a typical value be for time.deltatime? How does it know whether to go left or right in the top example?
In the code you were wondering about, with Input.GetAxis (“Horizontal”) it gets the value based on the keys you press (default arrow keys, left or right). So that’s how it knows. If you press left, it will go left, right it will go right. Input.GetAxis script reference
Break it down: transform.Translate ( 10f * Time.deltaTime * Input.GetAxis ( “Horizontal” ), 0, 0); 10f base speed Time.deltaTime multiplied with base speed makes it move at the same speed regardless of fps Input.GetAxis (“Horizontal”) sets the value based on the key the player press. (Example: Left = -1, Nothing = 0, Right = 1).
Time.deltaTime is the time since the last frame. It goes right or left depending on the value returned from Input.GetAxis, which ranges from -1.0 to 1.0.