Hi,
Im trying to get a Collision with the terrain, but I can't load the terrain. The error is: Runtime Error 7128 - Terrain does not exist. But the terrain does exist and I checked if I mixed the numbers up but I didnt.
Here's my code:
Sw=1024:Sh=768
set display mode Sw,Sh,32,1
set window off
sync on : sync rate 0
hide mouse
`Set Text
set text font "Verdana"
set text size 15
set text to bold
ink rgb(200,200,0),0
load image "Media/texture.bmp", 1
load image "Media/detail.tga", 2
make object terrain 3
set terrain heightmap 3, "Media/map.bmp"
set terrain scale 3,19.535, 3.5,19.535
set terrain split 3, 16
set terrain tiling 3, 4
set terrain light 3, 1, -0.25, 0, 1, 1, 0.78, 0.5
set terrain texture 3, 1, 2
build terrain 3
make object cube 1,1
Color object 1, RGB(255,0,0)
Position object 1, 255,0 ,255
speed# = 0.4
Do
`rotates the object only if of the key q isn't pressed
If KEYSTATE(16)=0
MMx = MouseMoveX()
Y# = WrapValue(Object Angle Y(1)+MMx): Yrotate Object 1,Y#
endif
`Controling the object
if upkey()=1 or KEYSTATE(17)=1
Move object 1, speed#
endif
if downkey()=1 or KEYSTATE(31)=1
move Object 1, -(speed#)
endif
if rightkey()=1 or KEYSTATE(32)=1
Move object right 1, speed#
endif
if leftkey()=1 or KEYSTATE(30)=1
Move object left 1, speed#
endif
if KEYSTATE(57)=1
position object 1, object position x(1) , object position y(1), object position z(1)
endif
if upkey()=1 AND downkey()=1 or KEYSTATE(17)=1 AND KEYSTATE(31)=1 or leftkey()=1 AND rightkey()=1 or KEYSTATE(30)=1 AND KEYSTATE(32)=1
Move object 1, 0
endif
`Camera Position befor viewing arround
opx1# = object position x(1)
opy1# = object position y(1)
opz1# = object position z(1)
`Free Cammoving
if KEYSTATE(16)=1
position camera 0, opx1#, opy1#+ReqCamHeight#-3.0, opz1#
if mouseclick()=0
xrotate camera camera angle x()-mousemovey()*0.25
yrotate camera camera angle y()+mousemovex()*0.25
if camera angle x()>80 then xrotate camera 80
if camera angle x()<-60 then xrotate camera -60
endif
if mouseclick()>0 then CamDis#=CamDis#-mousemovey()*0.25
CamDis#=CamDis#+mousemovez()*0.25
if CamDis#>-15 then CamDis#= -15
if CamDis#<-300 then CamDis#=-300
move camera CamDis#
if camera position y()<-60 then position camera camera position x(),-60,camera position z()
mousemovex()=0
mousemovey()=0
endif
`Camera Position after viewing arround
opx# = object position x(1)
opy# = object position y(1)
opz# = object position z(1)
`get the groundheight of the terrain
ObjHeight# = Get Terrain Height(3,opx#,opy#)
Position Object 1,opx#,ObjHeight#+1.0,opz#
Camheight# = ObjHeight#+ReqCamHeight#
`Set Camera to follow if q isn't pressed
if KEYSTATE(16)=0
TrackAngle = 0:
ReqCamHeight# = 7.0
camsmooth = 7
ColFlag = 0
Camdis# = 15
`Set Camera tp Follow
point camera 0,Opx#,Opy#+5,Opz#
Set Camera To Follow Opx#,ObjHeight#,Opz#,WrapValue(Object Angle Y(1)+TrackAngle),Camdis#,Camheight#,Camsmooth,ColFlag
endif
`Text
center text sw/2,50,"FPS "+str$(screen fps())
Sync
Loop
It's not a bug it's a feature
