Hi All,
I want to rotate object 180 deg when i press Right arrow key same as Left arrow key to -180 deg.
How do i do this.Help me.Thx.In unity c#
Use Input.GetKeyDown() and Transform.Rotate().
if (Input.GetKey(KeyCode.RightArrow) && rotate == true){
transform.eulerAngles = new Vector3(0, 0, 180); //or which axis you want to rotate
rotate = false;
Invoke(“ResetRotate”, 2f);
}
void ResetRotate(){
rotate = true;
}
try with this even tho Transform.Rotate() is pretty much same but it doesnt work in some cases
Thank you guys, ill try this.