Please, could anyone tell me whats wrong with this code, basically when i run it, my player model is miles away from where it should be. I am using 3DS Max to do the models if thats any help at all :) I think it's deffinitely something to do with the code before the main loop but i don't know what the problem is.
Here is my code:
Graphics3D 800,600
SetBuffer BackBuffer()
;COLLISION VARIABLES
;///////////////////////
Const TRACK_COL = 1 ;track collision type
Const CAR_COL = 2 ;car collision type
;///////////////////////
;LOAD 3D OBJECTS
;/////////////////////////////
Global cam_piv = CreatePivot()
Global cam = CreateCamera()
CameraRange cam,1,10000
Global light = CreateLight()
;/////////////////////////////
;///////////////////////////////////////////////
Global player = LoadMesh("models/ship.3ds") ;player craft model
Global track_model = LoadAnimMesh("models/track.3ds") ;track model
Global pos = FindChild(track_model,"pos") ;find position point in track
Global dir = FindChild(track_model,"dir") ;and direction point
Global track = FindChild(track_model,"track") ;extract main track from model
;////////////////////////////////////////////////
;POSITION OBJECTS
;///////////////////////////////////////////////////////////////
PositionEntity player,EntityX(pos),EntityY(pos),EntityZ(pos) ;position the player then face
PointEntity player,dir ;them in the right direction
;///////////////////////////////////////////////////////////////
;///////////////////////////////////////////////////////////////
EntityParent cam_piv,player
PositionEntity cam_piv,0,5,-10
PointEntity cam,cam_piv
;///////////////////////////////////////////////////////////////
;**************
;MAIN GAME LOOP
;**************
;//////////////////
While Not KeyHit(1)
player_control
update_cam
UpdateWorld
RenderWorld
Flip
Wend
End
;//////////////////
;*********
;FUNCTIONS
;*********
;PLAYER CONTROL
;///////////////////////////////
Function player_control() ;function for all player controls
If KeyDown(200) Then
MoveEntity player,0,0,1
EndIf
If KeyDown(208) Then
MoveEntity player,0,0,-1
EndIf
If KeyDown(203) Then
RotateEntity player,EntityPitch(player),EntityYaw(player)+1,EntityRoll(player)
EndIf
If KeyDown(205) Then
RotateEntity player,EntityPitch(player),EntityYaw(player)-1,EntityRoll(player)
EndIf
End Function
;///////////////////////////////
;UPDATE CAM
;///////////////////////////
Function update_cam() ;function for updating the camera movements to track the player
PointEntity cam,cam_piv
MoveEntity cam,0,0,EntityDistance(cam,cam_piv)-10
PointEntity cam,player
End Function
;///////////////////////////
And here is an image of my screen in 3DS Max:

The 2 boxes, represet two points - Position and direction (the player is placed at the position point, then turned to face the direction point). As you can see, they are on the track here, but when i run my code the player is not placed where it should be.
Thanks
|