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: SupportsInt, position: float3, rotation: Quaternion = [0.0, 0.0, 0.0, 1.0], speed: SupportsFloat = 0) None
Move a kart to a specific location.
- update(self: pystk2.WorldState) None
Update this object with the current world state
- property aux_ticks int property
Ticks since ready
- 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.typing.NDArray[numpy.float32] property
Distance down the track of each line segment (float N x 2)
- property path_nodes numpy.typing.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.typing.NDArray[numpy.float32] property
Width of the path segment (float N)
- property successors list[list[int]] property
For each node, its successors (N lists)
- 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.typing.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.typing.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 energy float property
Remaining collected energy
- property finish_time float property
Time to complete race
- property finished_laps int property
Number of laps completed
- property front numpy.typing.NDArray[numpy.float32] property
Front direction of kart 1/2 kart length forward from location
- property has_finished_race bool property
True if the kart has finished the race
- property id int property
Kart id compatible with instance labels
- property is_on_road bool property
Whether the kart is on track
- 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.typing.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 node int property
Closest node
- property overall_distance float property
Overall distance traveled
- property player_id int property
Player id
- property position int property
Current position of this kart in the race
- property powerup pystk2.Powerup property
Powerup collected
- property race_result bool property
Did the kart win the race?
- property rotation numpy.typing.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.typing.NDArray[numpy.float32] property
Width, height and length of kart
- property skeed_factor float property
Skid factor
- property speed float property
Speed of the kart in meters/second
- property velocity numpy.typing.NDArray[numpy.float32] property
Velocity of kart
- property velocity_lc numpy.typing.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