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:
And the functions in it:
The mesh2 is the collision mesh
Thanks for any help!
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!