What is the difference?

So I am doing Argon Assault and was wondering on what the difference of the thing I am doing on the x axis is different from the y axis when I am just adding the yThrow. Keep in mind that I still get the same behavior.

    float xThrow = Input.GetAxis("Horizontal");
    float yThrow = Input.GetAxis("Vertical");

    float xOffSet = xThrow * Time.deltaTime * controlSpeed;
    float newXPos = transform.localPosition.x + xOffSet;

    transform.localPosition = new Vector3
        transform.localPosition.y + yThrow,

Is it okey if I do this?

float newXPos = transform.localPosition.x + (xThrow * Time.deltaTime * controlSpeed);
float newYPos = transform.localPosition.y + (yThrow * Time.deltaTime * controlSpeed);


Welcome back to our community! :slight_smile:

In many cases, there are multiple ways to make something work in Unity, and Rick cannot show all of them. Furthermore, he writes his code in a way that is readable for him. Since this is a pure matter of personal preference, you may rename your variables, add more variables, etc. As long as your code follows the same logic, the output will be the same. And if your code works, it’s a solution by definition.

Has your question been answered?

See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms