Help , I'm trying Coding Script Movement in 2D Game

Hey ,Wat’s up Guys , I want Some help , I want to made a 2D Game , this game look like Tank 1990 (nes console) , So I draw a Tank , And I want how to do Movement script , what I want is when i hold upward the tank goes up and the Z axis rotation 180 , and when Downward pressed the tank goes Down and the Z axis rotation 0 , and when the leftward button pressed the Tanks goes to the left and the Z axis rotation 90 ,and the Invest for rightward , So I write this Script :

if(Input.GetAxis(“Vertical”) > 0.0f){
move = Input.GetAxis(“Vertical”)*Speed;
transform.position.y += move * Time.deltaTime;
transform.rotation.z = 180;

}else if(Input.GetAxis(“Vertical”)< 0.0f){
move = Input.GetAxis(“Vertical”)*Speed;
transform.position.y += move * Time.deltaTime;
transform.rotation.z = 0;
}

if(Input.GetAxis(“Horizontal”)> 0.0f){
move = Input.GetAxis(“Horizontal”)*Speed;
transform.position.x += move;
transform.rotation.x = 90;

}else if(Input.GetAxis(“Horizontal”)< 0.0f){
move = Input.GetAxis(“Horizontal”)*Speed;
transform.position.x += move;
transform.rotation.x = -90;
}

But the Script work only when I pressed the upward or the downward , but when I pressed the left / right the tanks goes to the left /right but It didn’t rotate :(:(:frowning: , the rotation stay 180 when I pressed left/right ,
So what’s the Problem :face_with_spiral_eyes::face_with_spiral_eyes:? and is transform.rotation.z is the Right function I should use for this movement.
Thanks in Advance :|:|:|

transform.rotation is a quaternion… don’t try to set quaternion components directly.

have a look at the reference page:

specifically the bit relating to EulerAngle (that’s the x/y/z type of rotation you’re probably used to)

Thanks for your attention ,
and It work , thanks man, :smile: :smile: