Game state

PySTK also exposes the internal state of the game.

class pystk2.WorldState
class Phase
DELAY_FINISH_PHASE = 9
FINISH_PHASE = 11
GO_PHASE = 6
IN_GAME_MENU_PHASE = 12
MUSIC_PHASE = 7
RACE_PHASE = 8
READY_PHASE = 4
RESULT_DISPLAY_PHASE = 10
SERVER_READY_PHASE = 3
SETUP_PHASE = 1
SET_PHASE = 5
TRACK_INTRO_PHASE = 0
UNDEFINED_PHASE = 13
WAIT_FOR_SERVER_PHASE = 2
property name str property
property value int property
static set_kart_location(kart_id: int, position: float3, rotation: Quaternion = [0.0, 0.0, 0.0, 1.0], speed: float = 0) None

Move a kart to a specific location.

update(self: pystk2.WorldState) None

Update this object with the current world state

property ffa pystk2.FFA property

Free for all match info

property items List[pystk2.Item] property

State of items

property karts List[pystk2.Kart] property

State of karts

property phase pystk2.WorldState.Phase property

World status phase

property players List[pystk2.Player] property

State of active players

property soccer pystk2.Soccer property

Soccer match info

property time float property

Game time

class pystk2.Track
update(self: pystk2.Track) None
property length float property

length of the track

property path_distance numpy.ndarray[numpy.float32] property

Distance down the track of each line segment (float N x 2)

property path_nodes numpy.ndarray[numpy.float32] property

Center line of the drivable area as line segments of 3d coordinates (float N x 2 x 3)

property path_width numpy.ndarray[numpy.float32] property

Width of the path segment (float N)

class pystk2.Player
property camera pystk2.Camera property

Camera parameters of the player

property kart pystk2.Kart property

Kart of the player

class pystk2.Camera
class Mode
CLOSEUP = 1
FALLING = 7
LEADER_MODE = 3
NORMAL = 0
REVERSE = 2
property name str property
property value int property
property aspect float property

Aspect ratio

property fov float property

Field of view

property mode pystk2.Camera.Mode property

Camera mode

property projection readonly_memoryview property

Projection matrix (float 4x4)

property view readonly_memoryview property

View matrix (float 4x4)

class pystk2.Item
class Type
BANANA = 1
BONUS_BOX = 0
BUBBLEGUM = 4
EASTER_EGG = 6
NITRO_BIG = 2
NITRO_SMALL = 3
property name str property
property value int property
property id int property

Item id compatible with instance data

property location numpy.ndarray[numpy.float32] property

3D world location of the item

property size float property

Size of the object

property type pystk2.Item.Type property

Item type

class pystk2.Kart
property angular_velocity numpy.ndarray[numpy.float32] property

Angular velocity of kart

property attachment pystk2.Attachment property

Attachment of kart

property distance_down_track float property

Distance traveled on current lap

property finish_time float property

Time to complete race

property finished_laps int property

Number of laps completed

property front numpy.ndarray[numpy.float32] property

Front direction of kart 1/2 kart length forward from location

property id int property

Kart id compatible with instance labels

property jumping bool property

Is the kart jumping?

property lap_time float property

Time to completion for last lap

property lives int property

Lives in three strikes battle

property location numpy.ndarray[numpy.float32] property

3D world location of the kart

property max_steer_angle float property

Maximum steering angle (depends on speed)

property name str property

Player name

property overall_distance float property

Overall distance traveled

property player_id int property

Player id

property powerup pystk2.Powerup property

Powerup collected

property race_result bool property

Did the kart win the race?

property rotation numpy.ndarray[numpy.float32] property

Quaternion rotation of the kart [w, x, y, z]

property shield_time float property

Second the shield is up for

property size numpy.ndarray[numpy.float32] property

Width, height and length of kart

property speed float property

Speed of the kart in meters/second

property velocity numpy.ndarray[numpy.float32] property

Velocity of kart

property velocity_lc numpy.ndarray[numpy.float32] property

Velocity of kart (in the kart referential)

property wheel_base float property

Wheel base (distance front to rear axis)

class pystk2.Powerup
class Type
ANVIL = 10
BOWLING = 3
BUBBLEGUM = 1
CAKE = 2
NOTHING = 0
PARACHUTE = 9
PLUNGER = 5
RUBBERBALL = 8
SWATTER = 7
SWITCH = 6
ZIPPER = 4
property name str property
property value int property
property num int property

Number of powerups

property type pystk2.Powerup.Type property

Powerup type

class pystk2.Attachment
class Type
ANVIL = 1
BOMB = 2
BUBBLEGUM_SHIELD = 6
NOTHING = 9
PARACHUTE = 0
SWATTER = 3
property name str property
property value int property
property time_left float property

Seconds until attachment detaches/explodes

property type pystk2.Attachment.Type property

Attachment type

class pystk2.Soccer
property ball pystk2.SoccerBall property

Soccer ball information

property goal_line Annotated[List[Annotated[List[float3], FixedSize(2)]], FixedSize(2)] property

Start and end of the goal line for each team

property score int[2] property

Score of the soccer match

class pystk2.SoccerBall
property id int property

Object id of the soccer ball

property location numpy.ndarray[numpy.float32] property

3D world location of the item

property size float property

Size of the ball