Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
1 registered members (henrybane), 1,499 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
addforcelocal or addvellocal ? #296494
11/01/09 11:08
11/01/09 11:08
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
I'm working with ODE and everything works fine. I have an biplane which flies, lands, takes off, etc. But there is a problem when it flies towards the earth (perpendicularly). Here is my code:
Quote:
if(key_w) {
if (m2 <= 5000){m2 += 30;}}
if(m2 >= 4000){ f =8879;}
if (m2 < 4000){ f = 0;
}
phent_addcentralforce (my, vector(0,0, f), nullvector);
if(key_q)
{
phent_addtorquelocal (my, vector(-30,0,0) );
}
if(key_e)
{
phent_addtorquelocal (my, vector(30,0,0) );
}
if (key_s){m2 -= 20;
}
if(key_w == 0)
{
if(m2 > 0){m2 -= 5;}
}

phent_addforcelocal ( my, vector(m2,0,0),nullvector);

where m2 is force applied (thrust), which increases with time.... g is gravity = -386.... adn f is lift force f = 8879, since the mass of the plane is 23. When I fly horizontally wverything is ok, but when i fly towards the ground the plane flies backwards away from the ground if "w" is pressed, instead of flying faster since also gravity force acts on it.
I tried to write addvellocal instead of addforcelocal, but now the plane flies forward if "w" is pressed, but does not fall on the ground (when directed towards it) if "w" is not pressed, though there is gravity acting on t.....
Does anyone know what can be the problem?? and why it behaves so weirdly?


Last edited by BastovBros; 11/01/09 11:10.

a generator of dull questions smile
Re: addforcelocal or addvellocal ? [Re: BastovBros] #296515
11/01/09 14:17
11/01/09 14:17
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
after 2 hours I solved this problem on my own. I just put the fps_max and ph_fps_max_lock equal to 50, now almost everything works fine. Yet I have a new question. Every plane has its center of mass where its engine is set, since engine is the heaviest part. But in my plane, the center of mass is just at the center of the plane, so it does not properly fall down, not lke normal planes. I have PH_BOX, so it behaves as if it is a box, how to make the engine understand that the plane's tale is lighter than its engine part? I cannot make it PH_POLY, since it is a moving object.

Last edited by BastovBros; 11/01/09 14:18.

a generator of dull questions smile
Re: addforcelocal or addvellocal ? [Re: BastovBros] #296531
11/01/09 15:44
11/01/09 15:44
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
you can add the gravity using VECTOR* vPos but it will give also angular speed


3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: addforcelocal or addvellocal ? [Re: BastovBros] #299049
11/20/09 16:10
11/20/09 16:10
Joined: Mar 2007
Posts: 197
Y
yorisimo Offline
Member
yorisimo  Offline
Member
Y

Joined: Mar 2007
Posts: 197
Can you make two PH_BOXs (one for the front and one for the back of the plane) attached with a constraint with one being heavier than the other? Don't make the visible plane in two separate parts though


Joris Lambrecht
My Contributions: Relative Rotation, Window Sizing
Re: addforcelocal or addvellocal ? [Re: yorisimo] #299187
11/22/09 03:46
11/22/09 03:46
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
yorisimo's response seems ok, i guess you can also use:

phent_addforcelocal (ENTITY* entity,VECTOR* vForce,VECTOR* vPos );

where vPos is the location on the plane you want to add a specific force, may be able to use it to push the front down a bit.. but really why do you need this? if you want the front to appear heavy, cant you just keep tilting it down a bit and increase speed based on the tilt angle?


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