I'm mucking around with physics for my submarine model (am not yet decided if I want to write my own yet).

How can I simulate stability so that the boat will naturally gravitate to an upright neutral position?

This is what I have so far:

Code:
//--set physics--
ph_setgravity (vector(0, 0, 0));
	
phent_settype (my_submarine, PH_RIGID, PH_BOX);
phent_setmass (my_submarine, 3, PH_SPHERE);
phent_setfriction (my_submarine, 0); 
phent_setdamping (my_submarine, 30, 60); 
phent_setelasticity (my_submarine, 20, 0); 

//--INPUT--
if( key_r ) sub_thrust.x+=10;
if( key_f ) sub_thrust.x=10;
if( key_v ) sub_thrust.x-=10;
phent_addforcelocal( my_submarine, sub_thrust, nullvector );
		
if( key_a ) phent_addforcelocal( my_submarine, vector(0,-50,0), vector(-30,0,0) );

if( key_d ) phent_addforcelocal( my_submarine, vector(0,50,0), vector(-30,0,0) );

if( key_w ) phent_addforcelocal( my_submarine, vector(0,0,50), vector(50,0,0) );

if( key_s ) phent_addforcelocal( my_submarine, vector(0,0,-50), vector(50,0,0) );



Last edited by Sub_Game; 01/27/10 12:03.

A7 Commercial
First person submarine combat simulator project
http://alexanderforeman.webs.com/fightersubgame.htm