Game Loop
The previous chapter described the custom_ui
and imports
methods. This chapter will lay out the game loop. We start with the template code supplied by OmniStep:
Start
The start
method is called once when the OmniStep operator begins running. This is where you can initialize variables, call methods, and define private variables. The data
class passed to this method is described in the next chapter
Update
The update
method is called every frame. This method corresponds to the viewport update, not the Blender timeline. In this template, when the user presses the action1
input ( Left Mouse by default), it displays a message in the bottom of the viewport with the content of the variable my_string
.
Late Update
There is an additional optional method called late_update
, which is called after the player and the animation data is updated. This can be useful for correcting elements that 'lag' behind the player for a single frame.
Here is an excerpt of the OmniStep update loop showing the positions of the update
and late_update
function:
Done
The done
method is called once when you end or abort the operator. The done
method has an additional parameter: canceled
, a boolean that indicates whether the user pressed Esc or Enter.