From BlenderWiki

Jump to: navigation, search
Blender3D FreeTip.gif
IMPORTANT! Do not update this page!
We have moved the Blender User Manual to a new location. Please do not update this page, as it will be locked soon.

Rigid Body Physics Object Type

Probably the most common type of object in the Game Engine. It will give/receive collisions and react with a change in its velocity and its rotation. A Rigid Body ball would begin rotating and roll down (where a Dynamic ball would only hit and slide down the ramp).

The idea behind Rigid Body dynamics is that the mesh does not deform. If you need deformation you will need to either go to Soft Body or else fake it with animated Actions.

In the example game demo, Frijoles, the Rigid Body type is represented by the Boulders that spawn from the top of the level. Notice how they tumble and roll in response to the collisions with the Arena.

For more documentation, see the Top BGE Physics page.

Options

Blender3D FreeTip.gif
bpy Access
Note that most of these properties are accessible through the non-BGE scripting API via bpy.data.objects["ObjectName"].game, which is of type bpy.types.GameObjectSetting. This is useful so you can, for example, set a range of objects to have gradated values via a for-loop.


  • Actor - Enables detection by Near and Radar Sensors.
    • Default: On.
    • Python property: obj.game.use_actor
  • Ghost - Disables collisions completely, similar to No Collision.
    • Default: Off.
    • Python property: obj.game.use_ghost
  • Invisible - Does not display, the same as setting the object to unrendered (such as unchecking the "Camera" icon in the Outliner).
    • Demo: The "ClothCatcher" object in top of Frijoles.blend
    • Default: Off.
    • Python property: obj.use_render
  • Mass - Affects the reaction due to collision between objects -- more massive objects have more inertia. Will also affect material force fields. Will also change behaviors if you are using the suspension and steering portions of Bullet physics.
    • Demo: The three different Boulder sizes in Frijoles.blend
    • Range: 0.01-10,000.
    • Default: 1.
    • Python property: obj.game.mass
  • Radius - If you have the "Collision Bounds: Sphere" set explicitly (or implicitly through having the Collision Bounds subpanel unchecked), this will multiply with the Object's (unapplied) Scale. Note that none of the other bounds types are affected. Also note that in the 3D View the display will show this for all types, even though it is only actually used with Sphere.
Basic Radius=1.5 Unapplied Scale Applied Scale Collision Bounds
Rolls, radius of 1 BU Rolls, radius of 1.5 BU (after "popping" upward) Rolls, radius of 1.5 BU Rolls, radius of 1 BU (!) Default (which is Sphere)
Slides, extent of 1 BU Slides, extent of 1 BU Slides, extent of 1.5 BU Slides, extent of 1.5 BU Box
"" "" "" "" Convex Hull
Slides, extent of 1 BU (but with more friction than above) Slides, extent of 1 BU (but with more friction than above) Acts insane Slides, extent of 1.5 BU Triangle Mesh
  • Form Factor - For affecting the Inertia Tensor. The higher the value, the greater the rotational inertia, and thus the more resistant to torque. You might think this is strange, considering Dynamic types do not have torque in response to collisions -- but you can still see this value's effects when you manually apply Torque.
  • Anisotropic Friction - Isotropic friction is identical at all angles. Anisotropic is directionally-dependant. Here you can vary the coefficients for the three axes individually, or disable friction entirely.
    • Range: 0.1-1.
    • Default: 1.
    • Python properties: obj.game.use_anisotropic_friction (boolean) and obj.game.friction_coefficients (a 3-element array).
  • Velocity - Limit the speed of an object. "0" is no limit.
    • Range: 0-1000.
    • Suboption: Minimum - The object is allowed to be at complete rest, but as soon as it accelerates it will immediately jump to the minimum speed.
      • Default: 0.
      • Python property: obj.game.velocity_min
    • Suboption: Maximum - Top speed of the object.
      • Default: 0. (Unlimited.)
      • Python property: obj.game.velocity_max
  • Damping - Increase the "sluggishness" of the object.
    • Range: 0-1.
    • Suboption: Translation - Resist movement. At "1" the object is completely immobile.
      • Range: 0-1.
      • Default: 0.0254.
      • Python property: obj.game.damping
    • Suboption: Rotation - Resist rotation, but not the kind of rotation that comes from a collision. For example, if a Motion Controller applies Torque to an object, this damping will be a factor.
      • Range: 0-1.
      • Default: 0.159.
      • Python property: obj.game.rotation_damping
  • Lock Translation - Seize the object in the world along one or more axes. Note that this is global coordinates, not local or otherwise.
    • Defaults: All off.
    • X - Python property: obj.game.lock_location_x
    • Y - Python property: obj.game.lock_location_y
    • Z - Python property: obj.game.lock_location_z
  • Lock Rotation - Same, but for rotation (also with respect to the global coordinates).
    • Defaults: All off.
    • X - Python property: obj.game.lock_rotation_x
    • Y - Python property: obj.game.lock_rotation_y
    • Z - Python property: obj.game.lock_rotation_z

Collision Bounds

Demonstration of a Local Bounding Box (left) and a Global Bounding Box (right). The monkeys are identical, except the right one has had its rotation applied with CtrlAR.

The first thing you must understand is the idea of the 3d Bounding Box. If you run through all the vertices of a mesh and record the lowest and highest x values, you have found the x min/max---the complete boundary for all x values within the mesh. Do this again for y and z, then make a rectangular prism out of these values, and you have a Bounding Box. This box could be oriented relative globally to the world or locally to the object's rotation.

The x extent, then, is half of the distance between the x min/max.

Setting the origin to Bounds Center instead of Median Center.

Throughout all of this you must be cognizant of the Object Origin. For the Game engine, the default CtrlAlt⇧ ShiftC,3 (Set Origin » Origin to Geometry) is unlikely to get the desired placement of the Collision Bounds that you want. Instead, you should generally set the origin by looking at the T-toolshelf after you do the Set Origin, and changing the Center from Median Center to Bounds Center. Blender will remember this change for future CtrlAlt⇧ ShiftC executions.

All Collision Bounds are centered on this origin. All boxes are oriented locally, so object rotation matters.


A final introductory comment: When you set the Collision Bounds on an object, Blender will attempt to display a visualization of the bounds in the form of a dotted outline. Currently, there is a bug: The 3D View does not display this bounds preview where it actually will be during the game. To see it, go to Game » Show Physics Visualization and look for the white (or green, if sleeping) geometry.

Now we can explain the various options for the Collision Bounds settings:

A convex hull sketch
Another way to create Collision Bounds -- By hand.
  • (Default)
    • For Dynamic and Static objects, it is a Triangle Mesh (see below).
    • For everything else, it is a Sphere (see below).
  • Capsule - A cylinder with hemispherical caps, like a pill.
    • Radius of the hemispheres is the greater of the x or y extent.
    • Height is the z bounds
  • Box - The x,y,z bounding box, as defined above.
  • Sphere -
    • Radius is defined by the object's scale (visible in the N properties panel) times the physics radius (can be found in Physics » Attributes » Radius.
    • Note: This is the only bounds that respects the Radius option.
  • Cylinder
    • Radius is the greater of the x or y extent.
    • Height is the z bounds.
  • Cone
    • Base radius is the greater of the x or y extent.
    • Height is the z bounds.
  • Convex Hull - Forms a shrink-wrapped, simplified geometry around the object.
  • Triangle mesh - Most expensive, but most precise. Collision will happen with all of triangulated polygons, instead of using a virtual mesh to approximate that collision.
  • By Hand - This is not an option in the Physics tab's Collision Bounds settings, but a different approach, entirely. You create a second mesh, which is invisible, to be the physics representation. This becomes the parent for your display object. Then, your display object is set to ghost so it doesn't fight with the parent object. This method allows you to strike a balance between the accuracy of Triangle Mesh with the efficiency of some of the others. See the demo of this in the dune buggy to the right.


Options

There are only two options in the Collision Bounds subpanel.

  • Margin - "Add extra margin around object for collision detection, small amount required for stability." If you find your objects are getting stuck in places they shouldn't, try increasing this to, say, 0.06.
    • Sometimes 0.06 is the default (such as on the Default Cube), but sometimes it is not. You have to keep an eye on the setting, or else learn the symptoms so you can respond when it gives you trouble.
    • You can see somewhat of a demo in Manual-BGE-Physics_Margins.blend. Here, the 0.0 settings are not clearly wrong, but they are different from the 0.06 settings. The 1.0 are simply wrong for the Box and Convex Hull objects. As you will notice, as of 2.62, the Margin has an odd effect on "Sphere" Collision Bounds types. It is almost imperceptibly different - so you will have to see the System Console to view the z-axis measurement. When you look at it, you will find that the purple row of Sphere bounds objects behave nearly identically in spite of the varying Margins.
    • The range is 0.0-1.0
    • If you're lazy/paranoid/unsure/diligent/bored, you can always run this on the Python Console to bump all 0.0 margins to 0.06: for obj in bpy.data.objects: obj.game.collision_margin = obj.game.collision_margin or 0.06
  • Compound - "Add children to form compound collision object." Basically, if you have a child object and do not have this enabled, the child's collisions will not have an effect on that object "family" (though it will still push other objects around). If you do have it checked, the parent's physics will respond to the child's collision (thus updating the whole family). For a demonstration, look at the far right of the top row of Manual-BGE-Physics-CollisionBounds.blend. In it, the Empty.001 has "Compound" unchecked, and so it falls down, while Empty.001 has it checked, and behaves properly. Python property: obj.game.use_collision_compound

Example Demo

To see working examples of most of the types of Collision Bounds configurations, see Manual-BGE-Physics-CollisionBounds.blend. The objects in red have some kind of flawed setting, and the green ones are the improved versions. It already has the Show Physics Visualization setting checked, so when you hit P you will see the bounds behavior in white wireframes.

Here you will see:

  • First Row:
    • A rotated Cube, with and without "Collision Bounds" checked (demonstrates that the default bounds does not rotate with the object rotation).
    • The difference between setting object origins to the default "Median" center versus the "Bounds" center.
    • Suzanne falling onto a custom shelf, perfectly made for her jaw shape. Only Triangle Mesh results in good behavior for this one.
    • Options:
      • (Excessively) increased Margin.
      • Compound when parenting is involved.
  • Second Row:
    • All 7 incorrect types of bounds (for this case).
    • 3 correct types (Convex Hull, Triangle Mesh, and custom).

Origin, Rotation, Scale

You must understand Applying Rotation/Scale with CtrlA and setting object Origins with CtrlAlt⇧ ShiftC. As mentioned in the Collision Bounds Section, the default behavior for Set Origin is to put it at the Median Center, but for the BGE you will usually want to use Bounds Center.

Some examples, as demonstrated in: Manual-BGE-Physics-TransformApply.blend

  • An object's bounds are defined by the min/max of all the vertices for each of the axes. The center of gravity is defined by its Origin (the orange dot in the 3d View).
  • Rotating does not affect the default collision bounds -- Collision Bounds option must enabled if you want to explicitly set the type of Collision Bounds so that you can choose a type where rotation has an affect.
  • Scaling does affect the object's bounds effective radius value, but if you CtrlAS (Apply Scale), the bounds pop back out to a larger size. You must set the Collision Bounds (or the Radius) explicitly if you want a more correct physics representation.

Create Obstacle

to do
 
  • It has to do with pathfinding and obstacle avoidance.
  • from the recent Recast (generating navmeshes) and Detour (navmesh/pathfinding) additions: http://code.google.com/p/recastnavigation/
  • World > Obstacle simulation

All Types

Summary - No Collision | Static | Dynamic | Rigid Body | Soft Body | Occlude | Sensor | Navigation Mesh | Character | Vehicle



Blender3D FreeTip.gif
This is the old manual!
For the current 2.7x manual see http://www.blender.org/manual/


User Manual

World and Ambient Effects

World

Introduction
World Background

Ambient Effects

Mist
Stars (2.69)


Game Engine

Introduction

Introduction to the Game Engine
Game Logic Screen Layout

Logic

Logic Properties and States
The Logic Editor

Sensors

Introduction to Sensors
Sensor Editing
Common Options
-Actuator Sensor
-Always Sensor
-Collision Sensor
-Delay Sensor
-Joystick Sensor
-Keyboard Sensor
-Message Sensor
-Mouse Sensor
-Near Sensor
-Property Sensor
-Radar Sensor
-Random Sensor
-Ray Sensor
-Touch Sensor

Controllers

Introduction
Controller Editing
-AND Controller
-OR Controller
-NAND Controller
-NOR Controller
-XOR Controller
-XNOR Controller
-Expression Controller
-Python Controller

Actuators

Introduction
Actuator Editing
Common Options
-2D Filters Actuator
-Action Actuator
-Camera Actuator
-Constraint Actuator
-Edit Object Actuator
-Game Actuator
-Message Actuator
-Motion Actuator
-Parent Actuator
-Property Actuator
-Random Actuator
-Scene Actuator
-Sound Actuator
-State Actuator
-Steering Actuator
-Visibility Actuator

Game Properties

Introduction
Property Editing

Game States

Introduction

Camera

Introduction
Camera Editing
Stereo Camera
Dome Camera

World

Introduction

Physics

Introduction
Material Physics
No Collision Object
Static Object
Dynamic Object
Rigid Body Object
Soft Body Object
Vehicle Controller
Sensor Object
Occluder Object

Path Finding

Navigation Mesh Modifier

Game Performance

Introduction
System
Display
Framerate and Profile
Level of Detail

Python API

Introduction
Bullet physics
VideoTexture

Deploying

Standalone Player
Licensing of Blender Game

Android Support

Android Game development