I am just beginning with Unity and doing the Space Shooter tutorial. I want to add a code to do a barrel role if the player inputs the left and right key twice. I went to scripting and found GetButton function but I really do not know if I am using it correctly. Any pointers??? With this code I was trying things out seeing but i am pretty sure it probably makes no sense to the compiler. if (Input.GetButton("button") && Time.time > 0) { rb.rotation = Quaternion.Euler(0.0f, 0.0f, rb.velocity.x * -roll); }
For working with left/right buttons use GetAxis method (see documentation here): Code (csharp): Input.GetAxis("Horizontal") And, Time.time - always will greater then 0, so this piece of code is surplus
I am already using getaxis function. Initial movement of my space craft is moving now do I use only that function in my if statement to get player input twice or double tap.