I think I found the problem
- need to use a bit of trigonometry to find the correct inclination
.
Here's the corrected subroutine :
inclina:
distVal#=30
yAng#=object angle y(1)
xPos#=object position x(1)
zPos#=object position z(1)
ang#=yAng#
frontX#=newxvalue(xPos#,ang#,distVal#)
frontZ#=newzvalue(zPos#,ang#,distVal#)
ang#=wrapvalue(yAng#+180)
backX#=newxvalue(xPos#,ang#,distVal#)
backZ#=newzvalue(zPos#,ang#,distVal#)
ang#=wrapvalue(yAng#+90)
leftX#=newxvalue(xPos#,ang#,distVal#)
leftZ#=newzvalue(zPos#,ang#,distVal#)
ang#=wrapvalue(yAng#-90)
rightX#=newxvalue(xPos#,ang#,distVal#)
rightZ#=newzvalue(zPos#,ang#,distVal#)
frontHeight#=get ground height(1,frontX#,frontZ#)
backHeight#=get ground height(1,backX#,backZ#)
leftHeight#=get ground height(1,leftX#,leftZ#)
rightHeight#=get ground height(1,rightX#,rightZ#)
xAng#=wrapvalue(asin((backHeight#-frontHeight#)/(2*distval#)))
zAng#=wrapvalue(asin((leftHeight#-rightHeight#)/(2*distval#)))
rotate object 1,xang#,angulo#,zang#
return
I assume this is what you want. As CattlerRustler said, there are other ways of doing this, although I'm not entierly sure what's best.
Another thing - Does your code run slow on your computer also? For so few lines, it doesn't half crawl along. Maybe something to do with having a position object command in the main loop
, although I am using DBC.
Oh well, hope that's helped!