Collisions -sample code-

Blitz3D Forums/Blitz3D Bug Reports/Collisions -sample code-

Graphics3D 640,480,16,2

Const UPS=60

cam=CreateCamera()

l=CreateLight()

period=1000/UPS
time=MilliSecs()-period

Global s1=CreateSphere()
Global s2=CreateSphere()

Const spaceship_type=1

EntityType s1,spaceship_type
EntityType s2,spaceship_type
EntityPickMode s1,2
EntityPickMode s2,2
EntityRadius s1,1,0.1
EntityRadius s2,1,0.1
Collisions spaceship_type,spaceship_type,1,1
ScaleMesh s2,1,.1,1
ScaleMesh s1,1,.1,1

PositionEntity s1,0,0,-50
PositionEntity s2,0,0,50

RotateEntity s1,0,0,0
RotateEntity s2,-100,0,0

PositionEntity cam,0,10,50
RotateEntity cam,90,0,0

Repeat
	Repeat
		elapsed=MilliSecs()-time
	Until elapsed
	ticks=elapsed/period
	tween#=Float(elapsed Mod period)/Float(period)
	
	For k=1 To ticks
		time=time+period

MoveEntity s1,0,0,1


		If KeyHit(1) End
		UpdateWorld	
	Next
	
	RenderWorld tween
	Flip

Forever


the disc stops short of the other disc even though it should touch

the problem seems to be with the Y argument of the entityradius.

See my reply here:
http://www.blitzbasic.com/Community/posts.php?topic=50255

hmm, looks like Ill have to just re-design the game.....

I just came here to report this bug myself. It's a big problem. The collision works just fine if the Y-radius is larger than the X-radius, but not the other way round. Here's my test code:

Graphics3D 800, 600, 0, 2

CreateCamera()
CreateLight()

S = CreateSphere(12)
ScaleMesh S, 2, 1, 2
PositionEntity S, 0, -2, 8
EntityColor S, 0, 255, 0
EntityRadius S, 1, 2
EntityType S, 1

S = CreateSphere(12)
ScaleMesh S, 2, 1, 2
PositionEntity S, 0, 4, 8
EntityColor S, 0, 0, 255
EntityRadius S, 1, 2
EntityType S, 1

Collisions 1, 1, 1, 1

While Not KeyHit(1)

	If KeyDown(57) Then MoveEntity S, 0, -0.1, 0

	UpdateWorld
	RenderWorld
	Flip

Wend
End


I think that if this collision isn't going to work in all cases, then it should at least say so in the docs. I'm going to have to use box or polygon collision which is much slower.