with this script below the balls bounce around but how could a call an event when the balls collide with a certain object in the level
thanks coma
////////////////////////////////////////////////////////////////////////////////////
var video_mode = 8; // 800x600 pixels
var video_depth = 32; // 32 bit mode
////////////////////////////////////////////////////////////////////////////////////
string mypro_wmb = <mypro.wmb>;
string box_mdl = <ball.mdl>;
////////////////////////////////////////////////////////////////////////////////////
var box_pos;
function makebox();
function create_box();
entity* box_ptr;
//x = random(2)-1; // x is set to a number between -1.0 and 0.999999
function main()
{
level_load (mypro_wmb);
wait(3);
camera.x = 0;
camera.y = -600;
camera.z = 240;
camera.pan = 90;
camera.tilt = -15;
box_pos.x = random(25)-25; // initial value, ranges from -95 to 105
box_pos.y = -71;
box_pos.z = 295;
}
function makebox()
{
box_pos.x = random(25)-25; // initial value, ranges from -95 to 105
box_pos.y = random(71)-71;
box_pos.z = 495;
box_ptr = ent_create(box_mdl, box_pos,create_box);
wait(1);
}
function create_box()
{
phent_settype(my, ph_rigid, ph_sphere); // enable physics for this ball
phent_setmass(my, 1, ph_sphere); // the ball has 1kg (2 lbs) and behaves like a sphere
phent_setfriction(my, 50); // friction
phent_setelasticity(my, 99, 0); // bounce a little
temp.x = 0;
temp.y = 0;
temp.z = -380; // earth gravity factor, g = 9.81 m/s2
ph_SetGravity(vector(0,0,-50 0)); // set gravity
while (my.z > -50) {wait (1);} // the ball has approached the floor
// sleep (1); // give it 3 more seconds
phent_setelasticity(my, 5, 0); // stop bouncing
phent_setmass(my, 10, ph_sphere); // the ball has 1kg (2 lbs) and behaves like a sphere
sleep (15); // give it 3 more seconds
phent_settype(my, 0, ph_sphere); // now stop the ball
// box_ptr = null; // free the pointer - we will assign it to a new ball
}
on_space=makebox;
Last edited by coma; 08/01/04 04:11.