- Home /
Need help with Making my tron bike turn 90 degrees
Iv been working on a tron game and i'm having trouble getting my bike to move 90 degrees when i hit the d or a keys. Also how do I make it so that you can hold down the button and it makes it turn constantly i want to have to press the button then lift my finger off then have to press again instead of being able to hold it down. Ill attach my script. I don't want it to turn smoothly i want it to turn 90 degrees at a time like the old tron games.
function Update ()
{
if(Input.GetButton("LEFT"))
{
transform.Rotate(Vector3.up * Time.deltaTime * -90);
}
if(Input.GetButton("RIGHT"))
{
transform.Rotate(Vector3.up * Time.deltaTime * 90);
}
}
Look at the Unity Scripting Reference for Input : http://docs.unity3d.com/Documentation/ScriptReference/30_search.html?q=Input
See there are 3 different conditions for GetButton (and Get$$anonymous$$ey)
Input.GetButton
Input.GetButtonDown
Input.GetButtonUp
click on each of these links and read the description, there you will find how to only detect when a key is pressed once.
Your answer
Follow this Question
Related Questions
Box colliders as trail 0 Answers
Shader supersampling 1 Answer
How do i make controls for 2 seperate characters in split screen 1 Answer
How do I create a glowing light around an object? 1 Answer
Send a mesh via Network 2 Answers