10. Physics

10.1. Physics Properties of an Entity

You can set the physics properties of an actor so all of its entities will inherit them. You can also edit each individual entity’s physics properties using Entity Parameters.

  • Has Physics? – Sets or returns whether the the entity has physics enabled
  • Type – Sets the entity to a Static or Dynamic physics object
  • Shape – Sets the shape of the entity to a Circle or Square for physics
  • Collision Width Scale – Scales the entity’s collision area proportional to its image width
  • Collision Height Scale – Scales the entity’s collision area proportional to its image height
  • Friction – Sets the entity’s friction for physics
  • Density – Sets the entity’s density for physics
  • Restitution – Sets the amount that an entity bounces during a physics collision
  • Fixed Rotation? – Sets or returns whether the the entity’s rotation is constant
  • Speed – Sets the speed of the entity
  • Speed Direction – Sets the direction that the speed will be applied in
  • Angular Speed – Applies torque to the entity

Rotation:

Rotations start at 0°(pointing up) turning clockwise to 360°

Rotation

Physics Units and Forces:

Actimator uses Box2D for physics. All physics units are metric and rely on the Scale Parameter(pixels per meter ratio).

  • Gravity – Measured in meters per second per second
  • Density – Measured in kilograms per meter squared
  • Friction – The friction parameter is usually set between 0 and 1, but can be any non-negative value. A friction value of 0 turns off friction and a value of 1 makes the friction strong
  • Restitution – Restitution is used to make objects bounce. The restitution value is usually set to be between 0 and 1. Consider dropping a ball on a table. A value of zero means the ball won’t bounce. This is called an inelastic collision. A value of one means the ball’s velocity will be exactly reflected. This is called a perfectly elastic collision.

This information is taken from the Box2D manual

10.2. Getting Physics Properties of an Entity

You can return the value of an entity’s physics property using the This Entity Command.

Get physics

10.3. Setting Physics Properties of an Entity

You can set physics properties using the This Entity Command.

Set physics

10.4. Physics Commands

Impulse Impulse

This command applies an impulse(hit) to the entity’s center of mass with the desired power and angle.

Impulse example

Speed Direction Speed direction

This command applies a constant velocity to the entity’s center of mass with the desired power and angle.

Speed direction example

Speed Vector Speed vector

This command applies a constant velocity to the entity’s center of mass with a power and angle that is determined by a vector.

Speed vector example

10.5. Physics Properties of a Scene

These three Scene properties control physics:

Scale

This is the pixel-to-meter ratio of physics on the scene. By default this is 30, so an entity that’s 60 pixels wide is considered 2 meters wide for physics.

Gravity x & y

The amount of gravity(in the form of a vector) on the x and y axis for the scene. For example, a Gravity y of 5 would cause entities with physics to fall at a rate of 5 meters per second squared.

Collision Outlines

Sets the physics’ bounding-box to be visible or hidden. This is useful for debugging how physics entities collide with one another, but is not necessary.

10.6. Getting Physics Properties of a Scene

You can return the value of a scene’s physics property using the Scene Property Command.

In the example pictured below, we are returning the values of Gravity x and Gravity y to apply the magnitude of the vector to a variable.

Get scene physics

10.7. Setting Physics Properties of a Scene

You can set the physics properties of the scene in the Property Explorer or you can set the value of a scene parameter while the game is running.

Here’s an example of setting the scene’s Gravity y value and turning off Collision Outlines from an entity’s program:

Set scene physics