I need help...I'm trying to make a box change angle as it goes up and down hills, as a car would. I have done a bit already, which works if you go straight up and straight down a hill, which i di by placing another object just infront of the player object and pointing the player at that. however, if you go down/up a hill at an angle, the car does not rotate to keep going flat on the ground, instead it stays flat, and sinks into the ground. Here is some simple source code, which I hope would help to explain it better. Try going up the hill at an angle. The code in in DBC...
hide mouse
cls rgb(100,255,100)
ink rgb(255,100,100),rgb(100,100,255)
box 10,10,245,245
save bitmap "greentex.bmp"
load bitmap "greentex.bmp",2
get image 2,0,0,256,256
delete bitmap 2
make object box 1,10,10,20
make matrix 1,1000,1000,10,10
prepare matrix texture 1,2,2,2
set matrix 1,1,1,1,0,1,1,1
for i=1 to 10
set matrix height 1,i,2,120
next i
update matrix 1
sync on
sync rate 0
position object 1,0,0,0
position camera 0,0,0
make object cube 2,4
hide object 2
do
set object rotation zyx 1
if upkey()=1 then x#=newxvalue(x#,a#,5) : z#=newzvalue(z#,a#,5)
if downkey()=1 then x#=newxvalue(x#,a#,-5) : z#=newzvalue(z#,a#,-5)
if leftkey()=1 then a#=wrapvalue(a#-3)
if rightkey()=1 then a#=wrapvalue(a#+3)
y#=get ground height(1,x#,z#)+2
position object 1,x#,y#,z#
yrotate object 1,a#
cx#=newxvalue(x#,wrapvalue(a#+180),40)
cz#=newzvalue(z#,wrapvalue(a#+180),40)
cy#=get ground height(1,cx#,cz#)+20
position camera cx#,cy#,cz#
point camera newxvalue(x#,wrapvalue(a#),20),y#,newzvalue(z#,wrapvalue(a#),20)
position object 2,newxvalue(x#,wrapvalue(a#),20),get ground height(1,object position x(2),object position z(2)),newzvalue(z#,wrapvalue(a#),20)
point object 1,object position x(2),object position y(2),object position z(2)
sync
loop
Does anyone know how to hake it go properly over the land??
Thanks very much
Robin
http://home.1asphost.com/thegameszone/arenabanner.gif[/img]
http://www.thegameszone.tk
[email protected]