This physics thing is fun


Thanks Fastlane. I threw a level together today. As you suggested I used a very small scale of 1 quant=0.1mm.

However, I've run into a couple of problems.

The collision detection is terrible. Even though the walls are at least ten quants thick, the ball often goes through them. It doesn't even seem to matter what speed the ball is travelling at.

The ball performs better when I use a spherical model. When I try using a sprite, even though I have set it to behave like a sphere, it doesn't. Also, when it gets in a narrow place, it sometimes slows down then speeds up again -not very realistic.

I have another problem with the GSjanFX plugin, but that is a different story, and I'll post elsewhere.

in the meantime here is the code I threw together for testing:

Code:
// pachinko2.wdl



path "C:\\Program Files\\GStudio6\\template"; // Path to WDL templates subdirectory

include <GSjanFX.wdl>;

var ball_pos[3];


//function declarations
function create_ball();
function init_sphere();
function init_pin();
function set_pins();





//string pachinko2_wmb = <pachinko2.wmb>;


function main()
{
level_load ("pachinko2.wmb");
wait(3);


camera.x = 0;
camera.y = -6500;
camera.z = 1500;
camera.pan = 90;
ball_pos.x = 900; // initial value, ranges from -95 to 105
ball_pos.y = 0;
ball_pos.z = -750;

// set_pins();
create_ball();
}





//entity* ball_ptr;


function create_ball()
{

ent_create("pachi_ball.mdl", ball_pos, init_sphere);



}

function init_sphere()
{
my.scale_x=2.5;
my.scale_y=2.5;
my.scale_z=2.5;
my.pan=90;

phent_settype(my, ph_rigid, ph_sphere);
// Enable physics for this ball; it will behave like a sphere when it comes to collisions

phent_setmass(my, 0.05, ph_sphere);


phent_setfriction(my, 30);
// Friction = 30 (could be 0...100)

phent_setelasticity(my, 60, 0);
// Bounce a little (value = 30, could be 0...100)

temp.x = 0;
temp.y = 0;
temp.z = -360;
ph_SetGravity(temp);
// Set gravity for the sphere (temp.z = -380 corresponds to the earth gravity factor, g = 9.81 m/s2)

//punch ball out shoot
phent_addforcelocal(my,vector(0,20000,0),nullvector);

while (my.z > -1000) {wait (1);}
// Wait until the ball has fallen off playing field

phent_settype(my, 0, 0);
// Now stop the ball; A6 commercial allows us to use one object (ball) at a time

wait(1);
ent_remove(me);
}

function init_pin()
{
phent_settype(my,ph_rigid,ph_cylinder);
}




function set_pins()
{

//this doesn't work properly yet





Last edited by A.Russell; 06/03/04 00:20.