racer home

Game Engine - Callbacks

 

Home A simple start.


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

Introduction

The Onyx scripts used in the game engine can have functions defined that are called when an event happens. For example, OnMultiplayerClientConnected() is called when the client connects succesfully to the server in a multiplayer game.

Callback order

It is important to know the order in which callbacks are called. This is because your callbacks may depends on certain state (like object position) to have been updated (or not yet).

Racer uses this order (the bold functions are called inside Onyx scripts):

Internally (in the C++ core) there is a slightly more complex loop to keep the scripting side and C++ sync:

Available callbacks

These callbacks can be defined in any Onyx script (and are called automatically by the engine):

Group

Function prototype

Description
Entities OnEntityCreated(int eid) called when an entity is spawned on the machine. Called on multiplayer servers and clients.
Graphics OnPreFrame() Called before a frame is rendered. Here it is time to setup the transform of objects.
  OnPreFrameLate() Called later than OnPreFrame, but still before a frame render. This is the place to setup the camera.
Multiplayer OnMultiplayerClientConnected() Called on the client when a client connects succesfully to the multiplayer server.
Timing OnTick() Called at the physics frequency
Events OnTriggerLine(int n) Called when a tracked entity crosses a triggerline.
  OnTrackLoaded() Called when a track has been loaded.

 

 


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

(last updated January 13, 2014 )