Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 1,405 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How much acceleration to counter gravity? #236705
11/16/08 00:03
11/16/08 00:03
Joined: May 2008
Posts: 150
Switzerland
Hitsch Offline OP
Member
Hitsch  Offline OP
Member

Joined: May 2008
Posts: 150
Switzerland

I'm trying to creat something like an autopilot for my vehicle. It's basicly a hovercraft, that is lifted off the ground by adding a local z-velocity. Much like a helicopter. The player can normaly control that amount, to adjust the altitude. Now alternativly, that amount should be automaticly controled so that the vehicle stays at it's present altitude.
I've tried setting the z-velocity to the amount of the gravity [ph_setgravity (vector(0, 0, -500))], but thats way to much, the vehicle goes up like a rocket.
Then I tried to find an amount by slowly adding velocity, but that turned out to be harder than I thought, because it's dependent on the framerate!
Is gravity dependent on the framerate, too?
Is there a way to calculate the amount of acceleration at the moment and then use it to counter it?
After trying for a long time I got everything messed up, but maybe it's a simple task for some of you.

Thx for you Help!

so long...

Code:
phent_settype(my, PH_RIGID, PH_BOX);
phent_setmass(my, 500, PH_BOX);
phent_setfriction(my, 5);	
phent_setdamping(my, 75,100);
phent_setelasticity(my, 10, 40);

ph_setgravity (vector(0, 0, -500))


Re: How much acceleration to counter gravity? [Re: Hitsch] #237744
11/21/08 22:26
11/21/08 22:26
Joined: May 2008
Posts: 150
Switzerland
Hitsch Offline OP
Member
Hitsch  Offline OP
Member

Joined: May 2008
Posts: 150
Switzerland
Nobody...?

Can nobody show me how to calculate the current acceleration (or velocity) of an entity?
vel_x, vel_y and vel_z are only for particles as I understand.

Re: How much acceleration to counter gravity? [Re: Hitsch] #237769
11/22/08 07:12
11/22/08 07:12
Joined: Nov 2005
Posts: 66
Spokane, WA, USA
Vonman Offline
Junior Member
Vonman  Offline
Junior Member

Joined: Nov 2005
Posts: 66
Spokane, WA, USA
If the object is at rest at the desired height, the force required to counter gravity is equal to the force of gravity itself. In other words, if the force of gravity is 500 and the DIRECTION of the force is DOWN, then the counter-force must be 500 and must be the inverse direction.

However, by countering only the gravity, you will not counter the additional downward force that comes from the downwards velocity (Z axis in this case).

I think you should code it so that there is a "target" height. If the hovercraft goes below that height, there must be an addition force in the upward direction to bring it back to the target height.
If it goes above the target height, then the "floating" force is reduced dependend on how height the hovercraft is above the target height.
If that force is taken away (or reduced), the hovercraft should fall back down again, but will go below the target once again though... you will need to add some kind of "dampener" to this process or it will bounce up and down forever.




hypothetical example:

target_height = ground_height + 10;

if(my.z < target_height)
{
float_force = target_height - my.z; // how FAR below the target height
// determins the float force

}

if(my.z > target_height)
{
float_force = my.z - target_height;
}

if(my.z == target_height)
{
float_force = -gravity; //TIMES* -1 because 500 is a negitive number
//and we want a positive version of 500
}



This is not full code, it would not work if you simply copied pasted it, but I hope you get my idea.

If this method works and you can dampen the process (so it does'nt bounce up and down forever) then it should behave like there is a repelling magnet below the hovercraft, or like it's on smooth water.


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1