Object Physics Properties

You can set a number of physical properties for an object that will set how it behaves when placed in a physics world.

When you first create a new object resource, there is a checkbox at the bottom on the left marked Uses Physics, which is normally not checked. Selecting this option will radically change the behaviour of your object when an instance of it is placed in a room, as this switches on the object's physical properties and means that its "traditional" movement and collision functions are no longer valid (but only when the room it is placed on is also marked as being a physics room. See - More About Rooms: Physics). When you check this, the object resource window expands to show the following:

Collision Shape

With the normal collision system you had your collisions based off of the mask of the sprite assigned to the object, but with the physics switched on, this is no longer the case. We need to assign a mask to the object ourselves (actually, this is really a "fixture", see The Physics Functions for more information), which can either be a circle, a rectangle or a polygon shape that you yourself define. Once you have selected the shape you can then click on the Modify Collision Shape button which will open the following window: This looks similar to the Path Editor, and functions in much the same way, however, depending on the mask you have chosen, it can be rather more restrictive:

Physics Properties

Once you have set up your shape, you then need to define the basic physical properties that your object is to have. These are configured by changing the following parameters:

Finally there are three extra options that can flagged as on or off for your fixture, Sensor, Start Awake and Kinematic. Each of these flags will change the behaviour of your fixture in the following ways:

NOTE: A sensor fixture will fire off the collision event when the collision first occurs only, meaning you don't get a stream of collision events as the two bodies continue to overlap (which is what would traditionally occur). If they stop overlapping and overlap subsequently there will be another collision event triggered.


Back: More About Objects
© Copyright YoYo Games Ltd. 2018 All Rights Reserved