Unity Version: 2021.1.7f1
OS: Windows 10
I'm currently making a small techno demo/foundation for my future project, where a player would drive a car. All the inputs so far are perfect, but the space bar. I plan on using the space bar as a key to activate a hand break. I wrote this code to emulate that:
void Update()
// This section of the code simulates the hand break
if (Input.GetKeyDown("space"))
{
RRWheel.brakeTorque = 200000.0f;
RLWheel.brakeTorque = 200000.0f;
Debug.log("The space bar is hit");
}
if (Input.GetKeyUp("space"))
{
RRWheel.brakeTorque = 0;
RLWheel.brakeTorque = 0;
}
The car doesn't stop. In fact, it accelerates for some reason. I checked the console and I saw that Unity doesn't even recognize my space bar for most of the time. I spent the next 10-15 minutes trying to figure out what the actual hell is going on by playing the game and smashing my space bar as frequently as I can. Weirdly, the unity recognized the space bar only 6-10 times. I'm very confused. Am I dumb?
↧