Soft Body Particles

Functions and information relevant to the use of the soft body particles in the physics world.

GameMaker: Studio uses the Box2D rigid body physics library, and as such does not permit soft body physics. However the Liquid Fun extension adds particles to the physics system, which permit the creation of simulated soft-bodies using rigid body physics. Basically, you can create a shape of particles that maintain cohesion and so simulate a full body, which, due to the interaction of the particles, gives the impression of a soft body. You can also use the physics particles to simulate liquids and other particle based physics systems.

Getting and Setting Particle Data

Before you start to create your physics particles you will need to set the basic physics properties for them, as you would a fixture in the regular physics. Note though that setting these properties will affect all particles created previously as well as any new particles that you create, so you would normally only use these functions at the start of the game or level. However there are specific functions available to set the particle flags for individual particles (and groups of particles) which will change their properties like "bounciness" or "viscosity", enabling you to create different types of particle within the ranges of these global settings.

The following functions are available for setting and getting global particle system data:

  1. physics_particle_count
  2. physics_particle_group_count
  3. physics_particle_set_max_count
  4. physics_particle_set_radius
  5. physics_particle_set_density
  6. physics_particle_set_damping
  7. physics_particle_set_gravity_scale
  8. physics_particle_get_max_count
  9. physics_particle_get_radius
  10. physics_particle_get_density
  11. physics_particle_get_damping
  12. physics_particle_get_gravity_scale

You also have the following functions available for setting flags on individual particles (or groups of particles), as well as for getting information, like position or colour, from a single particle or a single group:

  1. physics_particle_set_flags
  2. physics_particle_set_category_flags
  3. physics_particle_set_group_flags
  4. physics_particle_get_group_flags
  5. physics_particle_group_get_inertia
  6. physics_particle_group_get_centre_x
  7. physics_particle_group_get_centre_y
  8. physics_particle_group_get_vel_x
  9. physics_particle_group_get_vel_y
  10. physics_particle_group_get_ang_vel
  11. physics_particle_group_get_x
  12. physics_particle_group_get_y
  13. physics_particle_group_get_angle
  14. physics_particle_get_data
  15. physics_particle_get_data_particle
  16. physics_particle_group_get_data

Creating Particles

You can create particles in two ways - individually or in groups. Individual particles will behave exactly as defined by the global settings and the flags that were set when they were created, but groups of particles can exhibit different behaviours depending on their group flags. These group flags can be set to different values to give the group different properties, like penetration and rigidity.

The following functions are available for creating particles:

  1. physics_particle_create
  2. physics_particle_group_begin
  3. physics_particle_group_circle
  4. physics_particle_group_box
  5. physics_particle_group_polygon
  6. physics_particle_group_add_point
  7. physics_particle_group_end
  8. physics_particle_group_join
  9. physics_particle_group_delete

Deleting Particles

Not only can you create particles, but you can delete them too, either individually or in a region. The following functions are available for deleting particles from the system:

  1. physics_particle_delete
  2. physics_particle_delete_region_circle
  3. physics_particle_delete_region_box
  4. physics_particle_delete_region_poly

Drawing Particles

Unless you have activated the debug drawing using physics_draw_debug(), you won't see any particles on the screen when you create them. Therefore to actually see the particles, you need to draw them to the screen in the Draw Event of an instance using the following functions (note that you can also draw them using the regular draw_sprite functions if you get the data for each particle using the functionphysics_particle_get_data):

  1. physics_particle_draw
  2. physics_particle_draw_ext

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