How do you change your z axis in a movement script.
So im trying to make a C# script for a 2d game.
if(Input.GetKey (KeyKode.D)) transform.Translate(Vector2.Right x 8f x Time.Deltatime); transform.eulerAngles (x, y how do i make a rotation for z when pressing D? if I typ (0, 0, 90) I just get errors.
The player in this top view game starts moving upwards when pressing S and D/A. I thought if you make the ship rotate 90° to the left/right when pressing a/d this problem world go away.
Im very new to scripts sorry if this question is dumb. ty
Is there a reason you're not using transform.Rotate
?
http://docs.unity3d.com/ScriptReference/Transform.Rotate.html
Answer by allenallenallen · Dec 27, 2015 at 05:14 PM
Well, it's because you're new to coding. Look at the API. http://docs.unity3d.com/ScriptReference/Transform-eulerAngles.html
This is the correct way to use it:
transform.eulerAngles = new Vector3(0, 0, 90);