Collisions problem

Blitz3D Forums/Blitz3D Beginners Area/Collisions problem

I'm currently following the Blitz3D tutorials by Ray Diaz (excellent stuff so far ^^). However, I'm having a strange problem with collisions.

I'm finding that if I enable the line:
"Collisions PLAYER,PROPS,2,1"
It actually makes all my PROPS disappear!

It works perfectly fine with:
"Collisions PLAYER,PROPS,1,1", but this is of course not what I want. I looked through the sample source code and I can't figure out what it could be which is stopping my version from working properly.

any ideas?

Whoa. Strange. What Blitz3D version?

I checked - and I was still using 1.85, so I upgraded to Blitz 1.87 and I still have the problem. I think it's my code though.

Here is my code:
.basicsetup
Graphics3D 800,600,32,1
SetBuffer BackBuffer()

.lights
;light
Global light = CreateLight()
RotateEntity light,90,0,0

;Global
Global x#,y#,z#,terra_y#
Global flor1
Global kit,ttshoppe
Global nacar

;collision groups
Global SCENARY	= 1
Global PLAYER	= 2
Global CARPET   = 5
Global PROPS	= 4

;camera pivot
camera_pivot = CreatePivot()
EntityRadius camera_pivot,1.4
EntityType camera_pivot,PLAYER

;camera
Global camera = CreateCamera(camera_pivot)
CameraRange camera,1,1000
CameraFogMode camera,1
CameraFogRange camera,60,200
PositionEntity camera_pivot,-90,5.6,120

;sky
Global sky=CreateSphere (16,camera_pivot)
FlipMesh sky
ScaleEntity sky,100,100,100
PositionEntity sky,0,50,0
sky_tex = LoadTexture("sky.bmp")
EntityTexture sky,sky_tex

;weapon
Global weapon2 	= LoadMesh("gloc.3ds",camera_pivot)
weapon_tex2		= LoadTexture("glocmap.jpg")
EntityTexture 	weapon2,weapon_tex2

RotateEntity 	weapon2,12,170,14
ScaleEntity 	weapon2,0.01,0.01,0.01
PositionEntity 	weapon2,1,-1,1.5
EntityOrder 	weapon2,-1

;terrain
Global terrain=LoadTerrain("height2.jpg")
TerrainDetail terrain,2500,True
ScaleEntity terrain,3,15,3
PositionEntity terrain,-1000,0,-350
ter_tex = LoadTexture("terrain-texture.jpg")
EntityTexture terrain,ter_tex
EntityRadius terrain,0.2
EntityType terrain,SCENARY

;a floor
cube_tile=LoadTexture("floor.jpg")
flor1 = CreateCube()
	ScaleEntity flor1,8,0.06,13
	ScaleTexture cube_tile,0.5,0.5
	EntityTexture flor1,cube_tile
EntityType flor1,CARPET
EntityRadius flor1,0.4
PositionEntity flor1,10,6,120

;more floors
flor2 = CopyEntity(flor1)
flor3 = CopyEntity(flor1)
flor4 = CopyEntity(flor1)
PositionEntity flor2,-100,6,120
PositionEntity flor3,100,6,120
PositionEntity flor4,0,6,0

;abuela's kitchen
kit = LoadMesh("weapshop.3ds")
kit_tex = LoadTexture("kitchen.jpg")
EntityTexture kit,kit_tex
EntityType kit,PROPS
PositionEntity kit,10,6.5,128
ScaleEntity kit,0.08,0.08,0.08
EntityRadius kit,1.10

;tamsen toys
ttshoppe = LoadMesh("shop.3ds")
PositionEntity ttshoppe,10,6.5,112
RotateEntity ttshoppe,0,180,0
ScaleEntity ttshoppe,0.08,0.08,0.08
ttshoppe_tex=LoadTexture("ttshop.jpg")
EntityTexture ttshoppe,ttshoppe_tex
EntityType ttshoppe,PROPS
EntityRadius ttshoppe,1.10

;nacar thing
nacar = LoadMesh("pearlank.b3d")
nacar_tex = LoadTexture("eggo2.jpg",67)
EntityTexture nacar,nacar_tex
PositionEntity nacar,10,6.8,120
ScaleEntity nacar,0.005,0.005,0.005
EntityType nacar,PROPS
EntityRadius nacar,0.30

;a wooden fence
fence = LoadMesh("woodenfence.b3d")
PositionEntity fence,-107,5.8,109
RotateEntity fence,0,-90,0
ScaleEntity fence,0.1,0.1,0.1
fence_tex = LoadTexture("woodfence.bmp")
EntityTexture fence,fence_tex
EntityType fence,PROPS
EntityRadius fence,1

;more fences
fence1= CopyEntity(fence)
PositionEntity fence1,-107,5.8,113
fence2= CopyEntity(fence)
PositionEntity fence2,-107,5.8,117
fence3= CopyEntity(fence)
PositionEntity fence3,-107,5.8,121
fence4= CopyEntity(fence)
PositionEntity fence4,-107,5.8,125
fence5= CopyEntity(fence)
PositionEntity fence5,-107,5.8,129



; Collision Handling
Collisions CARPET,SCENARY,2,1
Collisions PLAYER,PROPS,2,1

.mainloop
;main loop
While Not KeyHit(1)
	
	If KeyDown(200) MoveEntity camera_pivot,0,0,0.05		; Press UP cursor
	If KeyDown(208) MoveEntity camera_pivot,0,0,-0.05		; Press DOWN cursor
	If KeyDown(203) TurnEntity camera_pivot,0,2,0			; Press LEFT cursor
	If KeyDown(205) TurnEntity camera_pivot,0,-2,0			; Press RIGHT cursor

	TouchGround(flor1)
	TouchGround(flor2)
	TouchGround(flor3)
	TouchGround(flor4)
	TurnEntity nacar,0.5,0.5,0

	
	UpdateWorld
	x# = EntityX(camera_pivot)
	y# = EntityY(camera_pivot)
	z# = EntityZ(camera_pivot)
		
	terra_y# 	= TerrainY(terrain,x#,y#,z#)+1.6
	PositionEntity camera_pivot,x#,terra_y#,z#
		
	RenderWorld
	Locate 5,5
	Print "Hello World"
	Print x#
	Print y#
	Print z#
	Flip 
	
Wend 

End


Function TouchGround(n$)									; function to test if an object is floating, and enforce gravity
	If Not EntityCollided(n$,SCENARY)
		PositionEntity (n$,EntityX(n$),EntityY(n$)-0.01,EntityZ(n$))
	EndIf
End Function


Just quickly looking through I noticed that you are passing the flor1 handle into a STRING variable in the function TouchGround. You should be passing it into an INT variable/
PositionEntity (n,EntityX(n),EntityY(n)-0.01,EntityZ(n))
BTW, your TouchGround function is being called before you execute UPDATEWORLD. It should most likely be the other way around.

I made those changes, but they made no difference, unfortunately. Thanks anyway though, you're probably right about my calling touchground too early.

Further experimentation shows that if I change the line to:
Collisions PROPS,PLAYER,2,2

The props appear fine, it's just mode "2,1" which causes me problems. That said, the props don't seem to be actually causing collisions. Very odd...

Any more ideas? ^^

EDIT: ack - strange! It just started working fine with "2,1" again, even though I didn't change any values... o_o; I'll continue with the tutorials then. Thanks for any help! ^^