| 262 | |
| 263 | == Collision types == |
| 264 | In Orxonox there are four collision types: static, kinematic, dynamic, none |
| 265 | |
| 266 | Depending on the collision type of a WorldEntity it will in a different way to a collision with an other WorldEntity. |
| 267 | |
| 268 | In the next example there is a StaticEntity with a model and a collision shape. If you try to push away the box with a spaceship you will fail. This is because a WorldEntity with collision type "static" will never react to collisions with other WorldEntities. It will stay at the same position forever. |
| 269 | {{{ |
| 270 | #!xml |
| 271 | <Model position="0,0,0" mesh="cube.mesh" scale3D="10000,1,1" /> |
| 272 | |
| 273 | <StaticEntity position="0,0,0" collisionType=static mass=10000> |
| 274 | <attached> |
| 275 | <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" /> |
| 276 | </attached> |
| 277 | <collisionShapes> |
| 278 | <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" /> |
| 279 | </collisionShapes> |
| 280 | </StaticEntity> |
| 281 | }}} |
| 282 | |
| 283 | In the following example we changed the collision type to "kinematic" and replaced the StaticEntity by a MovableEntity. It is still impossible to push away the box with the spaceship, but the moving box is able to push the spaceship. |
| 284 | |
| 285 | {{{ |
| 286 | #!xml |
| 287 | <Model position="0,0,0" mesh="cube.mesh" scale3D="10000,1,1" /> |
| 288 | |
| 289 | <MovableEntity position="0,0,0" velocity="20,0,0" collisionType=kinematic mass=10000> |
| 290 | <attached> |
| 291 | <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" /> |
| 292 | </attached> |
| 293 | <collisionShapes> |
| 294 | <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" /> |
| 295 | </collisionShapes> |
| 296 | </MovableEntity> |
| 297 | }}} |
| 298 | |
| 299 | To make it possible that the box may be pushed by the spaceship and the spaceship may be pushed by the box we need to change the collision type to "dynamic": |
| 300 | |
| 301 | {{{ |
| 302 | #!xml |
| 303 | <Model position="0,0,0" mesh="cube.mesh" scale3D="10000,1,1" /> |
| 304 | |
| 305 | <MovableEntity position="0,0,0" velocity="20,0,0" collisionType=dynamic mass=10000> |
| 306 | <attached> |
| 307 | <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" /> |
| 308 | </attached> |
| 309 | <collisionShapes> |
| 310 | <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" /> |
| 311 | </collisionShapes> |
| 312 | </MovableEntity> |
| 313 | }}} |
| 314 | |
| 315 | To completely deactivate the physics of a WorldEntity set the collision type to "none". |
| 316 | |
| 317 | A WorldEntity with the collision type "dynamic" may have damping parameters: |
| 318 | {{{ |
| 319 | #!xml |
| 320 | <MovableEntity position="0,-100,0" velocity="0,50,0" rotationaxis="0,1,0" rotationrate=1000 collisionType=dynamic lineardamping=0.1 angularDamping=0.01 mass=10000> |
| 321 | <attached> |
| 322 | <Model position="0,0,0" mesh="crate.mesh" scale3D="3,3,3" /> |
| 323 | </attached> |
| 324 | <collisionShapes> |
| 325 | <BoxCollisionShape position="0,0,0" halfExtents="15,15,15" /> |
| 326 | </collisionShapes> |
| 327 | </MovableEntity> |
| 328 | }}} |
| 329 | Since the linear damping is large the box will stop the linear movement after a few seconds. The low angular damping decreases the angluar velocity only slowly. |
| 330 | |
| 331 | Not every collision type is legal for every WorldEntity. The following table gives an overview over the legal collision types of common WorldEntities: |
| 332 | || || '''StaticEntity''' || '''MovableEntity, ControllableEntity, Pawn''' || '''Spaceship'''|| |
| 333 | ||'''dynamic'''|| ||X||X|| |
| 334 | ||'''kinematic'''|| ||X|| || |
| 335 | ||'''static'''||X|| || || |
| 336 | ||'''none'''||X||X|| || |
| 337 | |