Hello guest! Login or Register
Construct 2 r90

Released Friday, May 11, 2012 at 2:01:09 PM

28mb for Windows XP, Vista & 7

Free Download
Download Manual

Coming Soon

Physics behavior


The Physics behavior simulates realistic object physics. It is powered by Box2DWeb. For an example, see the Physics example on the Arcade. For more examples, there are several Physics example projects in the Examples folder in Construct 2's install directory.

The Physics behavior is relatively complex. The following tutorials are recommended to gain a basic understanding of how to use the Physics behavior and some important points to know before beginning to use it:
Physics in Construct 2: The basics
Physics in Construct 2: Forces, impulses, torque and joints
This manual section will not repeat the information in these tutorials. Instead it will simply describe each feature of the Physics behavior. The tutorials describe how Physics engines work, what the different types of joints are, the difference between impulses and forces, and so on in case you're not already familiar with them.

Using Physics in Construct 2


The Physics behavior simulates physics separately to the Construct 2 layout. Construct 2 will try to keep the Physics and Construct 2 "worlds" synchronised if one changes but not the other, but this can be unpredictable. For example, setting an object's position or angle will cause Construct 2 to teleport the corresponding object in the physics simulation to the object's new position, which does not always properly take in to account collisions. The same is true of using other Construct 2 behaviors at the same time as Physics.

Therefore it is highly recommended to control Physics objects entirely via the Physics behavior (by setting forces, impulses, torques etc.), rather than trying to manipulate objects by Set position, Set angle etc.

Another consequence is Physics won't respond to objects with the Solid or Jumpthru behaviors. These behaviors are totally redundant when using Physics and have no effect. Instead, use the Immovable property.

Physics properties


Immovable
If Yes, simulate the object having infinite mass. Its density is ignored and it will never move.

Collision mask
Use collision mask uses the object's collision polygon from the Image/Animations editor for physics collisions. If it doesn't have a collision polygon it will use the object's bounding box.
Bounding box ignores the object's collision polygon if any, and for the purposes of Physics collisions considers the object to be a rectangle.
Circle ignores the object's collision polygon if any, and for the purposes of Physics collisions considers the object to be a circle. This allows objects to smoothly roll along (like for example barrels). This is especially useful since object's collision polygons is made out of straight lines, so a smooth circle cannot be created that way.

Prevent rotation
Lock the object's angle so physics collisions cannot rotate it.

Density
The density of the physics object. Only used if Immovable is No. The object mass is calculated as its density multiplied by the area of its collision mask. The exact density values used are not important and have no specific units - only the relative density is significant (i.e. an object with density 6 will be twice as dense as an object with density 3).

Friction
The friction coefficient of the physics object from 0 (no friction) to 1 (maximum friction). This adjusts how easily objects move against each other while touching.

Elasticity
The elasticity (also known as restitution or bounciness) of the physics object, from 0 (inelastic, like a rock) to 1 (maximum elasticity, like a rubber ball). This affects how high objects bounce when hitting the floor.

Linear damping
The rate the object slows down over time while moving, from 0 (no slowdown at all) to 1 (maximum slowdown).

Angular damping
The rate the object slows down over time while spinning, from 0 (no slowdown at all) to 1 (maximum slowdown).

Physics conditions


The Physics behavior has no conditions.

Physics actions: Forces


Apply force
Apply force at angle
Apply force towards position
Apply a force on the object, either at an angle, towards a position, or with custom X and Y axis forces. Applying a force causes the object to accelerate in the direction of the force. Forces can be applied from an image point or the object's origin.

Apply impulse
Apply impulse at angle
Apply impulse towards position
Apply an impulse on the object, either at an angle, towards a position, or with custom X and Y axis impulses. Applying an impulse simulates the object being struck, e.g. hit by a bat. Impulses can be applied from an image point or the object's origin.

Set velocity
Set the object's current velocity directly, providing a speed in pixels per second for the X and Y axes.

Physics actions: Global settings


These actions affect Physics behaviors in general, not just the one it was set for.

Enable/disable collisions
By default, all Physics objects collide with each other. You can disable collisions between the object and another Physics object so they pass through each other. This affects all instances of both object types. Note: enabling collisions again when objects are overlapping can cause instability in the simulation.

Set stepping iterations
Set the number of velocity iterations and position iterations used in the physics engine. The default is 8 and 3 respectively. Lower values run faster but are less accurate, and higher values can reduce performance but provide a more realistic simulation.

Set stepping mode
Choose whether the Physics time step uses dt (delta time, for Framerate independent) or a fixed value. By default it uses a fixed time step to eliminate any randomness coming from dt, ensuring simulations are exactly reproducible every time. Set to Framerate independent to adjust the time step according to the framerate, which can cause the same simulation to have different results if run twice. For more information see Delta-time and framerate independence.

Set world gravity
Set the force of gravity affecting all Physics objects. By default this is a force of 10 downwards.

Physics actions: Joints


Create distance joint
Fix two physics objects at a given distance apart, as if connected by a pole.

Create revolute joint
Create limited revolute joint
Hinge two physics objects together, so they can rotate freely as if connected by a pin. Limited revolute joints only allow rotation through a certain range of angles, like the clapper of a bell.

Physics actions: Object settings


These set the corresponding properties. For more information, see Physics properties.

Physics actions: Torque


Apply torque
Apply torque towards angle
Apply torque towards position
Apply a torque (rotational acceleration) to the object, either directly, or towards an angle or position.

Set angular velocity
Set the angular velocity (rate of rotation) directly, in degrees per second.

Physics expressions


AngularVelocity
The current angular velocity (rate of rotation) of the physics object, in degrees per second.

CenterOfMassX
CenterOfMassY
The position of the center of mass of the physics object, as calculated by the physics engine. This depends on the collision mask property, and is not necessarily in the middle of the object.

Mass
The mass of the physics object, as calculated by the physics engine. This is the area of the object's collision mask multiplied by its density.

VelocityX
VelocityY
The current speed of the physics object, in pixels per second.

AngularDamping
Density
Elasticity
Friction
LinearDamping
These return the corresponding properties. For more information, see Physics properties.

Previous Entry
Jump-thru
Next Entry
Pin

Feedback on this page
How useful was this page for you?
Do you have any suggestions for this page?