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:
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.
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.
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.
What is a collision?
In Actimator, a collision occurs when the collision boundary of one entity overlaps another.
What happens during/after collision?
When two entities first collide, the
ON_STARTCONTACTevent is trigger. Any code contained in the
ON_STARTCONTACTevent will be executed at this time. This is also a good time to play collision sound effects.
ON_IMPACTevent 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 Impulseparameter.
The moment colliding entities are no longer overlapping, the
ON_FINISHCONTACTevent 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.
You can set the physics
Shapeof 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 Scaleand
Collision Height Scalecan be set to any number above 0. For example “1” equals 100%, “0.5” would be 50%, and “2” would be 200%.
To better match up an actor’s image with its collision boundary, you use
Image Left Offsetand
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”.
Entities that have their physics
Typeset 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.
Entities with a “Dynamic”
Typeare affected by all physics forces and all other physics entities.
3.7.6. Making Entities Move with Physics¶
Linear velocity (Speed)
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.