ArcBasicDocs

help/commands/3d_examples

EntityInTrigger.abs

61 lines of ArcBasic. Words in colour that are commands link to their help page. To run it, download ArcBasic, open the file and press F5.

Download EntityInTrigger.absAll files in this folder

EntityInTrigger.abs
; 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