Skip to content

Data Access

The main methods, start, update and done have all access to the data class. This holds a subset of OmniSteps parameters that you can use to access inputs, player and scene data.

Inputs

Inputs are monitored for four Action keys / buttons, defined in the add-on preferences. They are of the class InputState:

1
2
3
4
5
class InputState(Enum):
    IDLE = 'idle'       # No input action detected
    DOWN = 'down'       # Input has just been pressed
    HOLD = 'hold'       # Input is being held down
    UP = 'up'           # Input has been released
You can access their states like this:
1
2
3
4
5
6
7
8
9
def update(self, context, data):
    if data.input.action1 == data.InputState.IDLE:    # Continuous
        pass
    if data.input.action1 == data.InputState.DOWN:    # Only True for one Frame
        pass
    if data.input.action1 == data.InputState.HOLD:    # Continuous
        pass
    if data.input.action1 == data.InputState.UP:      # Only True for one Frame
        pass

Additionally you have access to other inputs, but these are booleans and vectors. Here the complete list of available inputs:

data.input.action1      # InputState
data.input.action2      # InputState
data.input.action3      # InputState
data.input.action4      # InputState

data.input.forward      # bool
data.input.back         # bool
data.input.left         # bool
data.input.right        # bool
data.input.up           # bool
data.input.down         # bool

data.input.restart      # bool
data.input.respawn      # bool

data.input.pad_move     # Vector (Gamepad/Controller left stick)
data.input.pad_look     # Vector (Gamepad/Controller right stick)

Player State

There are several variables that reflect the current player state. The diagram below shows the most important values. The difference between view and aim is that view includes motion damping and camera banking effects, while aim does not.

alt text

data.player.view_pos        # Vector
data.player.view_vec        # Vector
data.player.view_mat        # Matrix (view directon is -Z)

data.player.aim_pos         # Vector
data.player.aim_vec         # Vector
data.player.aim_mat         # Matrix (view directon is -Z)

data.player.root_pos        # Vector
data.player.root_mat        # Matrix
For each parameter, there is a Matrix supplied alongside the position and Vectors. Be aware that the Matrix has the view / aim in the -Z direction (due to Blender having a right-handed coordinate system).
data.player.velocity        # Vector
The current player velocity (m/s).
data.player.acceleration    # Vector
The current player acceleration (m/s²)
data.player.is_grounded     # bool
Is True when the player is considered in contact with the ground.
data.player.is_contact      # bool
Is True when the player is touching a wall on any side. This is used for the 'Wall Jump' feature.
data.player.is_teleport     # bool
Is True when a teleport is in progress.

Scene State

data.scene.real_timestep    # float
Timestep in seconds of the current viewport frame rate. (e.g. 0.01666.. at 60 fps)
data.scene.enable_animation # bool
True if the the OmniStep animation section is active.
data.scene.write_frame      # bool
As the viewport frame rate and the Blender playback frame rate differ, this variable is true when they overlap. So at 60 fps viewport and 30 fps Blender playback rate, approx. every other frame this is True.
Use this to determine if a keyframe for a custom animation needs to be set.
data.scene.current_frame    # int
Current scene frame.
data.scene.timestep         # float
Timestep in seconds of the current Blender frame rate. This is simply 1.0 / data.scene.framerate
data.scene.framerate        # float
Blender frame rate set in the Output panel. Same as RenderSettings.fps.