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.
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:
- physics_particle_count
- physics_particle_group_count
- physics_particle_set_max_count
- physics_particle_set_radius
- physics_particle_set_density
- physics_particle_set_damping
- physics_particle_set_gravity_scale
- physics_particle_get_max_count
- physics_particle_get_radius
- physics_particle_get_density
- physics_particle_get_damping
- 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:
- physics_particle_set_flags
- physics_particle_set_category_flags
- physics_particle_set_group_flags
- physics_particle_get_group_flags
- physics_particle_group_get_inertia
- physics_particle_group_get_centre_x
- physics_particle_group_get_centre_y
- physics_particle_group_get_vel_x
- physics_particle_group_get_vel_y
- physics_particle_group_get_ang_vel
- physics_particle_group_get_x
- physics_particle_group_get_y
- physics_particle_group_get_angle
- physics_particle_get_data
- physics_particle_get_data_particle
- physics_particle_group_get_data
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:
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:
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):