I didn't know exact how to search this one. But the problem i'm having is that I have a char loaded infront of the camera and it moves forward when I hit up and turns when I hit left and right etc... ( Though I notice it pivots with an arc instead of turning in place) and if a player moves to the end of the matrix my if statements should catch them but instead they can proceed outside the the matrix a couple of steps then they become stuck outside the matrix
My code:
Sync On
Sync Rate 100
Hide Mouse
Backdrop on
Set camera range 1,5000
Fog on
Fog distance 4000
Fog color RGB(128,128,128)
Color Backdrop RGB(128,128,128)
Rem make matrix
Make matrix 1,10000,10000,20,20
Rem texture matrix
Load image "grass09.bmp",1
Load image "floor.bmp",2
Prepare matrix texture 1,1,1,1
Fill matrix 1,1,1
rem Randomize the matrix
randomize matrix 1,1250
make object sphere 1,50
rem Load object
Load object "IDLE.x",2
`texture object 2,2
position object 2,5000,Get Ground Height(1,4000,5500),5500
rotate object 2,0,0,0
Rem Main loop
Do
oby#=object angle y(2)
set cursor 0,0
print obpx#
print obpy#
print obpz#
Rem allow object to respond to keypresses
if upkey()=1
XTest# = Newxvalue(obpx#,oby#,20)
ZTest# = Newzvalue(obpz#,oby#,20)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
move object 2,-10
endif
endif
if leftkey()=1 then yrotate object 2,wrapvalue(oby#-5)
if rightkey()=1 then yrotate object 2,wrapvalue(oby#+5)
obpx#= object position x(2)
obpz#= object position z(2)
obpy# = Get Ground Height(1,X#,Z#)
Rem position object at these co-ordinates
position object 2,obpx#,obpy#,obpz#
Rem Using the newxvalue and newzvalue functions, work out a
Rem camera position based upon objects location i.e. 100 Rem world units away and slightly above.
camx#= newxvalue(obpx#,oby#-0,50)
camz#= newzvalue(obpz#,oby#-0,50)
position camera camx#,obpy#+50,camz#
rem point camera at object
point camera obpx#,obpy#+25,obpz#
rem refresh screen and loop
Rem Refresh Screen
Sync
Loop
The code itself is a combination between several tutorials.
Another problem I have is when I use
the matrix will still look flat and only the camera will move up and down (though there is no visible hill there?!)
Anyways hope I explained my problem well. And sorry I didn't really know how to search this topic
Thanks for your time,
Red Kite
-minor edit to fix a variable name