interesting, when I add the code it will work but at the cost of the loss of movement and making the surroundings blank textured.
here's the full code
sync on
sync rate 60
set camera range 1,9999
load object "media\models\world.x",20
load image "media\gfx\world.png",76
texture object 20,76
rotate object 20,0,180,0
scale object 20, 20000,14000,20000
fog on
fog color rgb(100,100,100)
color backdrop rgb(50,50,50)
fog distance 3000
set ambient light 10
load music "media\music\main.wav",2
loop music 2
rem Make Gun
Load object "media\models\M249.x",1,2
Load image "media\gfx\M249.dds",20
Texture object 1,20
XRotate Object 1,180
Zrotate object 1,180
Yrotate object 1,180
Fix object pivot 1
Scale object 1,80,80,80
position object 1,7,-9,15
set object frame 1,200
Lock object on 1
set object speed 1,1
loop object 1,1,7
load sound "media\music\gunshot.wav",1 : // change to yours
FireShotDelay = 0
repeat
if mouseclick() = 1 and timer() > FireShotDelay
set object speed 1,10
play object 1, 1, 20 : // plug in your anim frames
if sound playing(1) = 1 then stop sound 1
play sound 1
FireShotDelay = timer() + 500
endif
load image "media\gfx\tree.png", 4
load object "media\models\tree.x", 2
texture object 2,4
scale object 2, 1000, 1000, 1000
position object 2,100,400,1
load object "media\models\tree.x", 3
texture object 3,4
scale object 3, 1000, 1000, 1000
position object 3,600,400,200
load object "media\models\tree.x", 6
texture object 6,4
scale object 6, 1000, 1000, 1000
position object 6,2000,230,2000
load object "media\models\tree.x", 5
texture object 5,4
scale object 5, 1000, 1000, 1000
position object 5,1500,130,3000
load object "media\models\tree.x", 7
texture object 7,4
scale object 7, 1000, 1000, 1000
position object 7,3000,130,-2000
load object "media\models\tree.x", 8
texture object 8,4
scale object 8, 1000, 1000, 1000
position object 8,2000,130,-1500
load object "media\models\tree.x", 4
texture object 4,4
scale object 4, 1000, 1000, 1000
position object 4,1000,400,600
load effect "media\effects\bump.fx",1,100
load object "media\models\building.x", 9
load image "media\gfx\building_D2.dds",9
texture object 9,9
scale object 9, 340, 340, 340
position object 9,-1000,347,-1434
load object "media\models\rubble.x",51
load image "media\gfx\rubble.dds",17
texture object 51,17
scale object 51,2000,3000,1000
position object 51,0,300,300
load object "media\models\rubble.x",52
texture object 52,17
scale object 52,2000,3200,1000
position object 52,0,350,-800
yrotate object 52,90
make light 1
make light 2
make light 3
position light 1,200,500,1
set light range 1,100000
set point light 2,300,500,50
rem Main
do
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)
`
cx#=camera position x() : cz#=camera position z()
Rem Control input for camera
`move forwards
If keystate(17)=1
cX# = Newxvalue(cX#,CameraAngleY#,10)
cZ# = Newzvalue(cZ#,CameraAngleY#,10)
Endif
`move backwards
If keystate(31)=1
cX# = Newxvalue(cX#,Wrapvalue(CameraAngleY#-180),10)
cZ# = Newzvalue(cZ#,Wrapvalue(CameraAngleY#-180),10)
Endif
`move left
If keystate(30)=1
cX# = Newxvalue(cX#,Wrapvalue(CameraAngleY#-90),10)
cZ# = Newzvalue(cZ#,Wrapvalue(CameraAngleY#-90),10)
Endif
`move right
If keystate(32)=1
cX# = Newxvalue(cX#,Wrapvalue(CameraAngleY#+90),10)
cZ# = Newzvalue(cZ#,Wrapvalue(CameraAngleY#+90),10)
Endif
`mouse movement
Yrotate camera CurveAngle(CameraAngleY#,OldCamAngleY#,24)
Xrotate camera CurveAngle(CameraAngleX#,OldCamAngleX#,24)
position camera cx#,1027-intersect object(20,cx#,1000,cz#,cx#,-1000,cz#),cz# `this is the main part of the code, use
`normal wsad controls with the x and z positions but intersect the terrain object with the y position
camx = camera position x (0)
camy = camera position y (0)
camz = camera position z (0)
cx#=camera position x() : cz#=camera position z()
sync
rem Debug
if keystate(41)=1
set cursor 0,0 : print "FPS: ";screen fps():print "X Position : " ,camx:print "Y Position : " , camy:print "Z Position : " , camz
endif
`
rem Update screen
sync
rem End loop
loop
Thankyou for everyone's help
Edit: the code I posted has the error I'd stated previously
Poloflece
Rust Pack WIP here http://forum.thegamecreators.com/?m=forum_view&t=178788&b=24