PhysicsBodyBullet body,enabled
Parameters
|
body - live physics body handle enabled - True or False |
Description
|
Enables extra continuous collision detection for a fast-moving body. Enables additional continuous collision detection against dynamic and kinematic bodies for a dynamic body, and wakes it. Ordinary continuous collision with static scenery already operates without this flag. Native bullets do not perform bullet-versus-bullet CCD and do not guarantee precise projectile collision timing, particularly initial overlaps or fast targets. For precise projectile tests use casts that account for relative motion. Static and kinematic bodies are rejected. Changing away from dynamic mode clears this flag. Stale/wrong-kind handles and invalid numeric inputs cause runtime errors. Object ownership is unchanged by these controls. Requires Extended mode. See also: ResetPhysicsBody, PhysicsBodyActive, PhysicsBodyMode, StepPhysics. |
Example
; PhysicsBodyBullet Example ; ------------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() Const PHYSICS_STATIC=0 Const PHYSICS_DYNAMIC=2 camera=CreateCamera() PositionEntity camera,7,2,-1 RotateEntity camera,5,80,0 light=CreateLight() RotateEntity light,45,-30,0 AmbientLight 60,60,60 ; An independent Box3D world with standard gravity world=CreatePhysicsWorld() ; Blue static floor ground=CreateCube() ScaleEntity ground,6,0.5,6 PositionEntity ground,0,-0.5,0 EntityColor ground,80,160,255 ground_body=CreatePhysicsBody(world,ground,PHYSICS_STATIC) ground_shape=PhysicsBodyBox(ground_body,12,1,12) ; A thin glass pane, only 4 cm thick pane=CreateCube() ScaleEntity pane,1.5,1.5,0.02 PositionEntity pane,0,1.5,0 EntityColor pane,150,220,255 EntityAlpha pane,0.6 ; The pane is kinematic, like a moving door that is standing still pane_body=CreatePhysicsBody(world,pane,1) pane_shape=PhysicsBodyBox(pane_body,3,3,0.04) ; A small ball that ignores gravity ball=CreateSphere(8) ScaleEntity ball,0.1,0.1,0.1 EntityColor ball,255,120,70 ball_body=CreatePhysicsBody(world,ball,PHYSICS_DYNAMIC) ball_shape=PhysicsBodySphere(ball_body,0.2) PhysicsBodyGravityScale ball_body,0 ResetPhysicsBody ball_body,0,1.5,-4,0,0,0 While Not KeyDown(1) ; Space fires the ball at the pane at 100 m/s If KeyHit(57) ResetPhysicsBody ball_body,0,1.5,-4,0,0,0 PhysicsBodyVelocity ball_body,0,0,100 EndIf ; B makes the ball a bullet, which also sweeps against moving bodies If KeyHit(48) bullet=Not bullet PhysicsBodyBullet ball_body,bullet EndIf StepPhysics world,1.0/60.0,4 ; 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: fire B: bullet Esc: exit" Text 0,20,"PhysicsBodyBullet ball_body,"+bullet Text 0,40,"Ball Z: "+EntityZ(ball)+" (the pane is at Z 0; above 0 means it went through)" Flip Wend FreePhysicsWorld world End
Index