PhysicsCollide
Sets whether two physics types collide.
PhysicsCollide type1,type2[,collide]
Parameters
- type1, type2
- physics types, 1 to 32 (they may be the same)
- collide (optional)
- True (the default) makes them collide; False lets them pass through each other
Description
Sets whether bodies of two physics types collide. To begin with, every type collides with every other.
PhysicsCollide 3,3,False stops bodies of type 3 colliding with each other. Triggers notice only the types that collide with their own.
Example
; Physics types and triggers example (an ArcBasic extension); Ghosts (blue) fall through the shelf; solid balls land on it.; The yellow zone counts what passes through itGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,5,-14TurnEntity camera,10,0,0light=CreateLight()RotateEntity light,50,30,0Const TYPE_BALL=2, TYPE_GHOST=3, TYPE_SHELF=4ground=CreatePlane()EntityColor ground,70,70,90EntityPhysics ground,1shelf=CreateCube()ScaleEntity shelf,6,.2,2PositionEntity shelf,0,4,0EntityPhysics shelf,1EntityPhysicsType shelf,TYPE_SHELF; ghosts pass through the shelf but still land on the groundPhysicsCollide TYPE_GHOST,TYPE_SHELF,False; a trigger: an invisible box that notices bodies inside itzone=CreatePivot()PositionEntity zone,0,1.5,0EntityPhysics zone,4EntityShape zone,1,12,3,2PhysicsDebug TrueWhile Not KeyHit(1) If Rand(0,15)=0 b=CreateSphere(8) ScaleEntity b,.3,.3,.3 PositionEntity b,Rnd(-5,5),9,0 EntityPhysics b,2 If Rand(0,1) EntityPhysicsType b,TYPE_GHOST EntityColor b,80,140,255 Else EntityPhysicsType b,TYPE_BALL EndIf EndIf UpdateWorld ghosts=0 For i=1 To TriggerCount(zone) If GetEntityPhysicsType(TriggerEntity(zone,i))=TYPE_GHOST Then ghosts=ghosts+1 Next RenderWorld Text 0,0,"Bodies in the zone: "+TriggerCount(zone)+" (ghosts: "+ghosts+")" FlipWendEnd
