3.7. Physics

3.7.1. Overview

Actimator comes with a built-in physics engine, which allows creating sophisticated games similar to Angry Birds in an easy and quick way.

Physics Scale (pixels per meter)

In the scene’s properties, you can set the Scale (pixels/meter) parameter. By default physics scale is set to 30, this causes the physics engine to simulate 30 pixels as on meter. For example, If and entity is 60 pixels wide, the physics engine will perform calculations for that entity as if it were two meters wide.

3.7.2. Enabling/Disabling Entity’s Physics

Each entity has a “Has Physics” property that, when set, causes the entity to participate in physics simulation. If an entity has physics enabled, it can move or rotate with a given velocity, collide with other physics entities, fall from the scene’s gravity, etc. If an entity does not have physics, it won’t react to other entities or physics forces.

You can enable/disable an entity’s physics at any time, there are a few ways to do this:

Actor Properties:

You can enable/disable physics in an actor’s properties. All entities created from an actor inherit that actors physics setting, entities that are already created retain their own physics settings.

Entity Properties:

If you have an entity created on the scene already, you can change its physics setting in the Property Editor. Only that entity’s physics will be changed.

Actor’s Program:

You can enable/disable physics in an actor’s program when a certain event is triggered. All entities of that actor will change physics settings when their programmed event is triggered.

3.7.3. Collision

What is a collision?

In Actimator, a collision occurs when the collision boundary of one entity overlaps another.

What happens during/after collision?

Collision start:

When two entities first collide, the ON_STARTCONTACT event is trigger. Any code contained in the ON_STARTCONTACT event will be executed at this time. This is also a good time to play collision sound effects.

During collision:

The ON_IMPACT event is triggered for the duration of a collision and is mostly used for checking the force of a collision. The physics engine will automatically try to move the entities apart until they are no longer colliding. The faster the physics engine has to move entities away from each other, the stronger the force of the collision. This force can be returned from the Impact Normal Impulse parameter.

After collision:

The moment colliding entities are no longer overlapping, the ON_FINISHCONTACT event will be triggered.

3.7.4. Adjusting Collision Boundaries

Regardless of how an entity looks, its collision boundary determines how it behaves in physics simulation. In the scene editor, collision boundaries show up as either a blue circle or square outlining each entity. There are options to set the size and shape of the collision boundary.

Physics Shape:

You can set the physics Shape of an entity to a “Square” or “Circle”.

Collision Width and Height Scale:

You can adjust the collision scale of an actor to resize the collision boundary to better match its image. Collision Width Scale and Collision Height Scale can be set to any number above 0. For example “1” equals 100%, “0.5” would be 50%, and “2” would be 200%.

Image Offset:

To better match up an actor’s image with its collision boundary, you use Image Left Offset and Image Top Offset. These values can be a positive or negative number that offsets the image of actor from its collision boundary.

3.7.5. Physics Type

There are two options you can set for physics type, “Static” and “Dynamic”.

Static Entities:

Entities that have their physics Type set to “Static”, are not able to move and are not affected by gravity. Other physics entities can collide with, and will bounce off of a static entity.

Dynamic Entities:

Entities with a “Dynamic” Type are affected by all physics forces and all other physics entities.

3.7.6. Making Entities Move with Physics

Linear velocity (Speed)

The Speed parameter sets the speed of an entity in meters per second.

Velocity direction (Speed Direction)

You can specify the direction to apply the speed force to an entity with the Speed Direction parameter, this can be a value between 0 and 360 degrees.

3.7.7. Applying Gravity to the Scene

You can apply gravity to a scene with the Gravity - X and Gravity - Y parameters, this will apply gravity to all dynamic entities. The value for the gravity parameters is set to meters per second per second.

3.7.8. Making Entities Move Without Physics

Although “Static” entities and non physics entities cannot move, you can still update their positions rapidly to give the illusion that they are moving. Just increase/decrease the x or y position of an entity on every tick or render event.