Search Recursive not working?

Blitz3D Forums/Blitz3D Beginners Area/Search Recursive not working?

I'm having some trouble here. I have a level mesh with a box called "start1" and i would like to retrieve the coordinates from that box each time i load a new level or area. I have the code and it works fine for other objects im "finding" (such as lights) but it refuses to place the cam & pivot at the box position.

Here is the code for the new level loading:
Function LoadArea(place$)
	
	Select place$
			
		Case "cliff"
			area=LoadSecMesh("cliff.3ds")
			toCave=GetEntFromName(area,"toCave") :EntityPickMode toCave,2
			toPlain=GetEntFromName(area,"light")
			startpos=GetEntFromName(area,"start1")
			bound=GetEntFromName(area,"bound")
			lightpos=GetEntFromName(area,"light"):HideEntity lightpos
			light1=CreateLight()
			PositionEntity light1,EntityX(lightpos),EntityY(lightpos),EntityZ(lightpos)
			EntityAlpha bound,0
			EntityType mesh2,COLPLANE
			
		Case "cave"
			area=LoadSecMesh("cave.3ds")
			toCliff=GetEntFromName(area,"toCliff") :EntityPickMode toCliff,2
			startpos=GetEntFromName(area,"start1")
			lightpos=GetEntFromName(area,"light"):HideEntity lightpos
			light1=CreateLight()
			PositionEntity light1,EntityX(lightpos),EntityY(lightpos),EntityZ(lightpos)
			EntityType mesh2,COLPLANE
			FlipMesh area
			FlipMesh mesh2
			FlushKeys
			
			
			
	End Select
	For p.player=Each player
		PositionEntity p\piv,EntityX(startpos),EntityY(startpos)+10,EntityZ(startpos)
		PositionEntity p\cam,EntityX(startpos),EntityY(startpos)+10,EntityZ(startpos)
		
	Next 
	
End Function 



And the functions in it:

Function LoadSecMesh(file$,parent=0)
	
	mesh=LoadAnimMesh(file$,parent)
	If mesh=0 Then RuntimeError "Mesh "+file$+" does not exist"
	
	
	mesh2=LoadMesh(file$,parent)
	EntityAlpha mesh2,0
	Return mesh
	
	
End Function 

Function GetEntFromName(mesh,name$)
	
	Return FindChild(mesh,name$)
	
End Function 

Function UpdateAreaSwitch()
	
	For p.player=Each player
		
		If CameraPick(p\cam,MouseX(),MouseY())=toCave
			If MouseHit(1)
				FreeEntity startpos:startpos=0
				FreeEntity area:area=0
				FreeEntity mesh2:mesh2=0
				LoadArea("cave")
		EndIf 
		EndIf
		
	Next 
	
End Function 


The mesh2 is the collision mesh

Thanks for any help!

Firstly, do you have collisions set for your pivot and cam?

Secondly, have you tried using the global flags?

PositionEntity p\piv,EntityX(startpos,true),EntityY(startpos,true)+10,EntityZ(startpos,true),true
		PositionEntity p\cam,EntityX(startpos,true),EntityY(startpos,true)+10,EntityZ(startpos,true),true


Does any of those things work?

If not i'll have a closer look at your code :o)

Your GetEntFromName function is completely redundant - why not call findchild directly?

I think the global flags thing Ross mentions is probably the issue but it seems strange that the light gets positioned ok.

Stevie

yes, p\piv have collisions
Nope, global flags didnt help

I've checked my mesh over and over and it seems fine.

I feel like im missing something..

Your main problem is what you load.

3DS has NEVER hierarchy so when you load it, you will always get the same result "child wise" as if you used loadmesh.

If you want hierarchy you will have to use at least X.
But as you use Blitz3D, using B3D would be the best decision.

okay, i cant export to .b3d but i can use .x (im using AC3D) ill try it.

hmmm... still no worky. What might be wrong?

If your pivot has collisions - make sure you 'resetentity' until it is at the desired start position.

okay, i feel stupid. The map was loaded before the player was made. But, now that I've switched them around, i get that entity startpos does not exist. Im guessing my mesh is the fault for that.
I've had a look at it and dont see any problems, but then I'm not the mesh composition expert.
Here it is:
http://ncreation.fuller.googlepages.com/cliff.x