Use Translate to move the camera forwards

Any reason not to swap out the complex use of transform.position with transform.Translate?

You can effecively get rid of a line of complex code: example

       float moveSpeed = 5f;
        transform.Translate(inputMoveDir * (moveSpeed * Time.deltaTime));

Also, a simpler way to do the camera rotation would be like this

        // rotate the object using E and Q keycodes
        if (Input.GetKey(KeyCode.E))
            transform.Rotate(Vector3.up, 90f * Time.deltaTime);
        if (Input.GetKey(KeyCode.Q))
            transform.Rotate(Vector3.up, -90f * Time.deltaTime);

It works fine, is less code and more readable. Any downside?

I don’t see any downsides to this.
There are often many paths to the same goal.

Privacy & Terms