Move forward exactly 0.2 unit

Hey all, need a small bit of code that I am having trouble finding oddly. I need to move my player forward (local forward not worldspace) exactly 0.2 units, I don’t need it to be done over time thankfully, an immediate move is better actually. The hard part is also that I never know what Y angle the player is facing, so transform.forward will be necessary. So a “+ Vector3(0.2, 0, 0)” type of code will not work for me.

I’ve seen tons of different forms of “Translate.forward * speed” but this doesn’t help me much at all since that doesn’t give me exact distances. I don’t need it to be a physics move either but if that’s what I have to do that is ok.

Any ideas?

transform.position += (transform.forward * 0.2f)?

Edit: transform.localPosition for local space

Yup! That did it! thanks!

also, weird that this was so hard to find. Google is not my friend on this one

1 Like