Common Shape Settings

From OxeyeWiki

Revision as of 12:25, 7 February 2010 by Jeb (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

These settings can be set for all entity shapes.

Parameter Expected Type Description
density A number The shape's density, measured in kilograms per cubic decimeter (about 1 for water). Defaults to 0. Note that this value must be greater than 0 if you are going to activate the entity with activateEntity.
friction A number The shape's friction. Defaults to 0.
restitution A number The shape's restitution (how "bouncy" it is). Defaults to 0 (no bounce).
isSensor A boolean Set this to true if the shape only should register intersections, but not collide. See getEntitySensorPoints.
filterCategory An integer This is a bitfield of collision categories this shape belongs to. Defaults to 0 (collides with everything).
filterMask An integer This is a bitfield of collision categories this shape should collide with. Defaults to 0 (collides with everything).
filterGroup An integer This is a single value that defines a specific filter group, defaults to 0 (disabled). The filter group can be used in two ways. Set it to a positive number and it will collide with all objects of the same (positive) filter group, regardless of filterMask. Set it to negative, and it will never collide with the collision group (negative or positive), regardless of filterMask.

For example, if an entity is going to shoot a bullet, you can use this to make sure that the bullet never collides with the shooter. Set the shooter's filterGroup to the shooter's body identifier (for example, 100), and then set the bullet's filterGroup to minus the shooter's body identifier (e.g. -100).

A good practise is to always set the filterGroup to the entity's body identifier.

userData A string Set this to a string if you need to identify individual shapes when a body collides. This string will be available in getEntityCollisions and getEntitySensorPoints.

See Also

Daisymoon Physics Lib
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox