why isn't this collision working?

Blitz3D Forums/Blitz3D Beginners Area/why isn't this collision working?

D_Town_Tony(Posted 2008) [#1]
I'm sure this is pretty simple, but I can't seem to figure out why the block in this example keeps falling through the floor. Shouldn't the collision detection stop it?

Graphics3D 800,600
SetBuffer BackBuffer()
WBuffer False
HidePointer
SeedRnd MilliSecs()


Global camera
Global Level_Model
Global Char_Pivot
Global Char_Model

Const TYPE_CHAR=1,TYPE_CHAR_JUMPBOX=2
Const TYPE_LEVEL=10

Collisions TYPE_CHAR,TYPE_LEVEL,2,2
Collisions TYPE_CHAR_JUMPBOX,TYPE_LEVEL,2,2

;frametweening
Global gameFPS = 60
Global framePeriod = 1000 / gameFPS
Global frameTime = MilliSecs () - framePeriod
framePeriod = 1000 / gameFPS
frameTime = MilliSecs () - framePeriod

;Load_Level
Load_Arena()
Load_Char()

While Not KeyDown(1)
Move_Char()
RenderWorld
Flip
Wend




Function Load_Arena()
Level_Model=CreateCube()
ScaleEntity Level_Model,20,1,10
EntityType Level_Model,TYPE_LEVEL
EntityPickMode Level_Model,2

light=CreateLight(1)
RotateEntity light,30,20,0

camera=CreateCamera()
CameraClsColor camera,25,50,75
CameraZoom Camera,3
PositionEntity camera,0,12,-50

End Function

Function Load_Char()
Char_Pivot=CreatePivot()
PositionEntity Char_pivot,0,12,0
EntityRadius Char_Pivot,8,13
ScaleEntity Char_Pivot,.5,.5,.5
EntityType Char_Pivot,TYPE_CHAR

Char_Model=CreateCube(Char_Pivot)
EntityColor Char_Model,50,0,0

End Function

Function Move_Char()
MoveEntity Char_Pivot,0,-.1,0
End Function


Stevie G(Posted 2008) [#2]
Firstly, there is no 'updateworld' in your main loop. You need this for collisions to work.

Secondly, the radius of the char_pivot is 13 but you are only starting it at height 12. When you take into consideration the level is of height 1 you are already penetrating the level ( distance between them is 11 ) so no collision will be recorded. If you set the starting height at >=14 it stops as expected - although not sure if this is what your after.

Stevie


D_Town_Tony(Posted 2008) [#3]
Thanks Stevie, thats exactly what I was looking for! I haven't touched Blitz in 3 years and am trying to "re-learn" things by grabbing code from stuff I made back then, so I figured it was something that I was overlooking, so thanks again!