Notes
Slide Show
Outline
1
Collisions
  • Andreas Klinko
  • Vinh Giang
  • Haris Bilal
2
Why is it useful?
  • Collisions between objects can be used to:
    • trigger action sequences
    • respond to the gamer
    • show an animation/explosion



3
References from DBPro
  • Pages 76-77, 84-85, 87-88, 98-99
  • User help
  • Forums-  DBPro and Code Snippets
4
Commands – settings
  • Set Collision On|Off object_no
  • Set Object Collision To Boxes| Spheres | Polygons
  • Set Global Collision On|Off
  • Set Object Radius object_no, radius#
  • Automatic Object Collision object_no, radius, response
  • Automatic Camera Collision camera_no, radius, response


5
Commands cont’d
  • Make Object Collision Box object_no,x1,y1,z1,x2,y2,z2,collision flag
  • Delete Object Collision Box
  • float = object collision x|y|z()


6
Collision Expressions
  • Used to detect object hit/collisions
  • Able to obtain coordinates via function calls



7
Collision Expr. cont’d
  • int = object hit(obj_1, obj_2)
  • int = object collision(obj_1, obj_2)
  • float = object collision radius(obj)
  • float = object collision center                                         x|y|z(obj)


8
Intersect Object
  • float = intersect object(obj, x, y, z, tox, toy, toz)
  • Useful for determining distances between a fast moving object and another object
9
Static Collisions
  • Make Static Collision Box x1,y1,z1,x2,y2,z2
  • int = Get Static Collision Hit (OX1, OY1, OZ1, OX2, OY2, OZ2, NX1, NY1, NZ1, NX2, NY2,NZ2)
  • float = Get Static Collision x|y|z ()
  • int = static line of sight(x1,y1,z1,x2,y2,z2, width, accuracy)
  • float = static line of sight x|y|z ()
10
Notes
  • Make sure objects are centered at the origin when exported from 3DCanvas
  • DarkBASIC is somewhat inconsistent when it comes to manage collisions, so test thoroughly
  • Use the Intersect Object command if you have a fast-moving projectile, otherwise the projectile might go through the target object.
  • Also, Intersect Object is useful for making your own collision detection algorithms