Hi, is there any way to know if a button is already pressed when I start the scene? For example, I have a car with the Handbrake active when I close the current scene, so, when I open the new scene, to have the Handbrake active again, I need to release the Handbrake and engage it again. So, I want to, don't need to release and engage the Handbrake again after switching scenes. How can I do it?
Create a class and attach it to a gameObject. In that class store the current value for the handbrake (bool handbrakeIsActive) which is set once the handbrake is set and released once the handbrake goes off. Also in that script just set DontDestroyOnLoad so it will survive scenes. Then once a scene is loaded you may set the handbrake status in Start() or OnLevelWasLoaded() or so by getting a reference to the manager class (singleton may be preferred) and getting the status.
Hi #Glockenbeat, thank you for your reply... But, using it's method, I'll don't know when the player release the button because Unity3D only know a button is released after the button is pressed, so for example: If I have the handbrake pressed on the new class and the Handbrake hardware is engaged (it means the button is pressed), when I release the Handbrake hardware, the Unity3D will not know that the handbrake button was pressed, so, the Handbrake variable will still be "True", in this way I'll still need to engage and disengage the Handbrake to have the result I need.
You may wanna try to check Input.GetKey(KeyCode.-your-key-here-) instead of KeyDown and KeyUp. This should even be true if you press the key before loading the scene. You gotta do that in Update though.
How do you start the loading process? Gui button or another key or any game related condition? I just tried it, it didn't work when i used a key to start the next scene. However, if i use a button this works.