ArcBasicDocs
3DPhysicsArcBasic extension

EntityCCD

Stops a fast physics body passing through thin walls.

EntityCCD entity[,enable]

Parameters

entity
entity handle
enable (optional)
True (the default) turns it on

Description

Turns on continuous collision detection for a dynamic body, so that it cannot pass through thin walls when moving fast. Without it, a body that moves further than its own size in one step can jump right through something thin.

Use it for bullets, fast balls and anything else small and quick; it costs a little time, so leave it off for ordinary bodies.

Example

EntityCCD.absOpen in editor
; Physics body settings example (an ArcBasic extension); A balloon that floats, a puck that stays flat, a fast bullet that; doesn't miss the thin wall, and a crate that shows when it sleepsGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,5,-14TurnEntity camera,15,0,0light=CreateLight()RotateEntity light,50,30,0ground=CreatePlane()EntityColor ground,70,90,70EntityPhysics ground,1; gravity scale below 0 makes a body float upwardsballoon=CreateSphere(12)PositionEntity balloon,-5,1,0EntityColor balloon,255,80,80EntityPhysics balloon,2,.1EntityGravity balloon,-.2EntityDamping balloon,.8,.8; the puck may only slide along X and Z and turn about its Y axispuck=CreateCylinder(16)ScaleEntity puck,.6,.15,.6PositionEntity puck,0,.15,-2EntityPhysics puck,2EntityShape puck,4EntityLockAxes puck,0,1,0,1,0,1EntityFriction puck,0; a thin wall and a fast bullet with continuous collision detectionwall=CreateCube()ScaleEntity wall,.05,2,2PositionEntity wall,6,2,0EntityPhysics wall,1crate=CreateCube()ScaleEntity crate,.5,.5,.5PositionEntity crate,2,4,2EntityPhysics crate,2While Not KeyHit(1)	If KeyDown(203) Then ApplyForce puck,-8,0,0	If KeyDown(205) Then ApplyForce puck,8,0,0	If KeyDown(200) Then ApplyForce puck,0,0,8	If KeyDown(208) Then ApplyForce puck,0,0,-8	If KeyHit(57)		bullet=CreateSphere(6)		ScaleEntity bullet,.1,.1,.1		PositionEntity bullet,0,2,0		EntityPhysics bullet,2,.05		EntityGravity bullet,0		EntityCCD bullet		SetEntityVelocity bullet,300,0,0	EndIf	If KeyHit(17) Then WakeEntity crate : ApplyImpulse crate,0,4,0	UpdateWorld	If EntitySleeping(crate) Then EntityColor crate,90,90,90 Else EntityColor crate,240,200,120	RenderWorld	Text 0,0,"Arrows: slide the puck   Space: fire at the wall   W: wake the crate"	FlipWendEnd

See also