R3d.Body:setType

From GiderosMobile
Revision as of 10:54, 18 December 2025 by MoKaLux (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Available since: Gideros 2019.10
Class: R3d.Body

Description

Sets the body type.

r3d.Body:setType(type)

There are three types of bodies: static, kinematic and dynamic.

A static body has infinite mass, zero velocity but its position can be changed manually. Moreover, a static body does not collide with other static or kinematic bodies.

A kinematic body has infinite mass, its velocity can be changed manually and its position is computed by the physics engine. A kinematic body does not collide with other static or kinematic bodies.

A dynamic body has non-zero mass, non-zero velocity determined by forces and its position is determined by the physics engine. Moreover, a dynamic body can collide with other dynamic, static or kinematic bodies.

For instance, you can use a static body for the floor, a kinematic body for a moving platform and a dynamic body for a rock that could fall on the floor.

When you create a new body in the world, it is of dynamic type by default.

Parameters

type: (number) the new body type, must be one of the following:

  • r3d.Body.STATIC_BODY 0
  • r3d.Body.KINEMATIC_BODY 1
  • r3d.Body.DYNAMIC_BODY 2

Example

plane.body:setType(r3d.Body.STATIC_BODY)
cube01.body:setType(r3d.Body.KINEMATIC_BODY)
cube02.body:setType(2)