Custom game states
RED4ext offers the possibility to attach custom game states to the game. These can be used to initialize or do some things before or after the game system are available, such as scripting system.
State functions
Every state has the following functions:
OnEnter
Called immediately after the state is activated. This function is called once by the game, so be careful what you want to do here. A good example is to initalize some memory that is needed later.
Return
The return value is not taken in consideration. It is recommended to always return
true
for future proofing.
OnUpdate
Called every frame. This function can contain more complex code.
Return
false
- if the state did not finish executing.true
- if the state finished executing.
OnExit
Called when the state is ending. This function is called once by the game, so be careful what you want to do here.
Return
The return value is not taken in consideration. It is recommended to always return
true
for future proofing.
Game's Life Cycle
Example
Last updated