Collision Detection?

Blitz3D Forums/Blitz3D Beginners Area/Collision Detection?

mesenberg(Posted 2005) [#1]
First, I dont have a problem with the Collisions() function but with EntityCollided().

Code:
Graphics3D 800,600
SetBuffer BackBuffer()

Const C_BOX=1

cam=CreateCamera()
PositionEntity(cam,-5,3,-5)

plane=CreatePlane()
EntityColor(plane,64,64,64)

cube1=CreateCube()
PositionEntity(cube1,1,1,1)
FitMesh(cube1,0,0,0,2,2,2)
EntityRadius(cube1,1)
EntityColor(cube1,200,20,20)
EntityType(cube1,C_BOX)
cube2=CreateCube()
PositionEntity(cube2,-5,2,2)
EntityRadius(cube2,1)
EntityColor(cube2,20,200,20)
EntityType(cube2,C_BOX)

;Main Loop
While Not KeyDown(1)

MoveEntity(cube2,0.01,0,0)

PointEntity(cam,cube2)

If (EntityCollided(cube2,C_BOX))
RuntimeError("Collision")
EndIf

UpdateWorld
RenderWorld
Flip

Wend
End

This code doesn't detect the collision. Ive looked at the space invaders example provided and a few others but I dont know how to get this EntityCollided to work.

-Mesenberg-


Shambler(Posted 2005) [#2]
You haven't set up collisions,

Collisions C_BOX,C_BOX,1,1  ;<---add this line
;Main Loop
While Not KeyDown(1)



mesenberg(Posted 2005) [#3]
Question answered, thank you

-Mesenberg-


WolRon(Posted 2005) [#4]
What are the forum codes?