DebugEntityCollider entity[,method][,recursive][,depth_test]
Parameters
|
entity - entity whose collision shapes to draw method (optional) - which shapes to show 0: the entity's selected source shape: radius, capsule or convex (default) 1: the EntityRadius ellipsoid only 2: the entity's mesh polygons as a wireframe 3: the EntityBox box only 4: the Box3D-cooked EntityConvex hull only recursive (optional) - True also draws shapes for every descendant of the entity; False (default) depth_test (optional) - True hides the shapes behind closer geometry, False draws them through everything; True (default) |
Description
|
Queues an entity's collision shapes - radius ellipsoid, box or polygons - for the next RenderWorld. Collision bugs are hard to see because the shapes are invisible: an entity collides with its EntityRadius ellipsoid or EntityBox box, not with its visible mesh. DebugEntityCollider draws those shapes exactly where the collision system sees them, so a character sinking into the floor or snagging on a doorway explains itself in one frame. Each shape has a fixed colour so you can tell them apart: radius and capsule sources are light green, EntityBox is orange, mesh polygons are pink, and a Box3D-cooked convex hull is purple. Method values 1 through 4 match the destination method codes used by Collisions. Method 0 follows whichever source definition was selected most recently by EntityRadius, EntityCapsule or EntityConvex. Method 2 draws every edge of the entity's mesh, which can be a lot of lines - the shared debug budget is 65,536 per frame - so point it at one entity rather than a whole level. Like every Debug command, the shapes live for exactly one RenderWorld: the queue is drawn by the next RenderWorld and then cleared, so call DebugEntityCollider every frame while you tune your collision setup. A method outside 0-4 stops the program with a runtime error. Requires Extended mode. See also: EntityRadius, EntityCapsule, EntityBox, EntityConvex, Collisions, DebugEntityBounds, ClearDebugDraw. |
Example
; DebugEntityCollider Example ; --------------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-9 light=CreateLight() RotateEntity light,45,45,0 ; A patrolling enemy with a box collider enemy=CreateCube() EntityColor enemy,220,60,60 EntityBox enemy,-1,-1,-1,2,2,2 ; An orbiting pickup with a sphere collider pickup=CreateSphere() ScaleEntity pickup,0.5,0.5,0.5 EntityColor pickup,255,210,40 EntityRadius pickup,1 show=True While Not KeyDown(1) ; Space toggles the debug overlay If KeyHit(57) Then show=Not show ; Move both entities so the colliders visibly follow them angle#=angle+1.5 PositionEntity enemy,4*Sin(angle),0,3 PositionEntity pickup,3*Cos(angle),1,3*Sin(angle) ; DebugEntityCollider queues the shape implied by EntityBox or EntityRadius If show Then DebugEntityCollider enemy DebugEntityCollider pickup EndIf ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: move camera Space: toggle overlay Esc: exit" If show Then Text 0,20,"Box from EntityBox, sphere from EntityRadius" Else Text 0,20,"Overlay off - press Space" Flip Wend End
Index