Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / My Gravity doesn't work correct, coud need some help :-)

Author
Message
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 9th Mar 2009 00:03
This is my idea:

I know the players position and its angle. I take the height of 8 points arround this position:

Quote: "angle_temp[0]= dbObjectAngleY(3) ;
for (i=1;i<8;i++)
angle_temp[i]= angle_temp[i-1] + 45;"

I increase angle_temp[i] by 45 degree. With a hypotenuse ( Hyp) of 15 I calculate the positions of this 8 points and get the height.

Quote: "float x_delta = sin(angle_temp[i])*Hyp;
float z_delta = cos(angle_temp[i])*Hyp;
x_temp[i]= x_pos + x_delta;
z_temp[i]=z_pos + z_delta;
y_temp[i]= dbGetTerrainGroundHeight(1,x_temp[i], z_temp[i]);
}"


Than I sort it for min- and maxheight. The difference of these values decides wether movement is effected or not:

Quote: "if (HeightDifference > 25)
{
correction = HeightDifference * 0.33;
Forward_delta = dbCOS(CorrectionAngle)*correction;
Side_delta = dbSIN(CorrectionAngle)*correction;
MovementForward = MovementForward - Forward_delta;
MovementSide = MovementSide + Side_delta;
"

MovementForward an MovementSide usually have already values from W,A,S or D.
I move the player with dbMoveObject and dbMoveObjectRight:

Quote: "if (MovementForward != 0)
{
dbSetObjectSpeed ( 3,55 );
dbLoopObject ( 3, 300 , 318);
dbMoveObject (3,MovementForward);
x_pos = dbObjectPositionX ( 3 );
z_pos = dbObjectPositionZ ( 3 );
ObjWasLooped = true;
}
if (MovementSide != 0)
{
dbSetObjectSpeed ( 3,80 );
dbLoopObject ( 3, 260 , 279);
dbMoveObjectRight (3,MovementSide);
x_pos = dbObjectPositionX ( 3 );
z_pos = dbObjectPositionZ ( 3 );
ObjWasLooped = true;
}"



And here is the whole code:

silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 9th Mar 2009 22:12
does anybody got a working gravity in terrainmap???

Login to post a reply

Server time is: 2024-09-30 19:25:31
Your offset time is: 2024-09-30 19:25:31