- Home /
Update for gui
Hey im developing for ios and i have heard a lot about assigning gui to an update function instead of a fixed. I can understand why but how would i go about doing this when the gui control an object like a car for instance.
So when i press on go the cars back wheels move, would it matter that my gui is in a fixed as the user has to hold go in order for the car to go. This is what i dont understand, do i have to put the go in update and check it in a fixed for it being pressed.
Answer by You! · Mar 24, 2012 at 05:24 AM
If this input is only required once, what you are doing should be fine. For example, if starting required pressing a GUI button and the rest of the controls were tilt based, what you are doing is perfect and also optimizing your game.
If you want to completely control the car from the GUI, it is preferred to use the "Update function" OnGUI(). For example, a button could be use to control whether or not the car is accelerating throughout the whole game, giving the player an option to stop or slow to a stop, depending on what is wanted.
Well at the momment all my menu items like pause and mainmenu are in update so as they are not effected by time.
For the game though when i hold a button down the car will move, so would it be better if i just leave it in fixed update. Rather than checking it.
Imagine i have a control manager script and it has all the controls in it and gui, to prevent less scripts being updated, and at the momment in fixed it says on touch addtorque,
Would it be a better solution to have a fixed update check say a off and on button inside the update which is controled by the touch
Just trying to squeze as much in without causing lag. $$anonymous$$y game is very physics based and is already close to lag on some objects, but this is before compression and lightmapping.
Thanks for the reply
Your answer
Follow this Question
Related Questions
Interpolated Fixed Timestep 2 Answers
What do I need to know when caching the results of a raycast every frame? 1 Answer
fixed update predicament 1 Answer
Which functions to which update, got confused 0 Answers
even just cubes moving seems choppy 1 Answer