Physics Variables

Objects have certain variables associated with them automatically when used in the physics world.

As with the "traditional" collisions and movement system, the physics system also has a series of instance variables assigned to each instance of an object when it is created. Some of these properties can be defined by the user in GML, but many are read-only and still more are only applicable in the collision event.

Variables

The following variables exists in all physics enabled objects and they can be read to and written to (ie: changed) using code from instances and scripts:

  1. phy_active
  2. phy_angular_velocity
  3. phy_angular_damping
  4. phy_linear_velocity_x
  5. phy_linear_velocity_y
  6. phy_linear_damping
  7. phy_speed_x
  8. phy_speed_y
  9. phy_position_x
  10. phy_position_y
  11. phy_position_xprevious
  12. phy_position_yprevious
  13. phy_rotation
  14. phy_fixed_rotation
  15. phy_bullet

Read Only Variables

Certain variables are read-only variables, which means that the information they contain cannot be changed through instance code or scripts (but it can be changed internally by GameMaker: Studio which is why these are variables and not constants). The following table shows the read-only variables that exist in all physics enabled objects:

  1. phy_speed
  2. phy_com_x
  3. phy_com_y
  4. phy_dynamic
  5. phy_kinematic
  6. phy_inertia
  7. phy_mass
  8. phy_sleeping

Collision Only Variables

Finally, there are a number of temporary variables that exist in physics enabled objects and are created only in the collision event. These variables are like those listed above and are read-only:

  1. phy_collision_points
  2. phy_collision_x
  3. phy_collision_y
  4. phy_col_normal_x
  5. phy_col_normal_y


Back: Physics
© Copyright YoYo Games Ltd. 2018 All Rights Reserved