How can i add one object at a time when two objects collided?
because in the 3d game that i make the object which is hit will release multiple objects per hit.
But i think the release object and the one that hit collide also upon release. how do i fix this?
Any idea from you guys? please advise.
here is my code:
// function : triggers bounce movement of the ball entity
//-------------------------------------------------------------------------------------------
void bounce_ball()
{
if (you)
{
if((you._ball==10) && (my._ball==10))
{
set(you,FLAG2);
set(my,FLAG2);
}
else
{
snd_play(explosion,100, 0);
effect(particle_ball,maxv(1,40*time_step),my.x,vector(0,0,5));
vec_to_angle(my.pan, bounce);
my.pan += 5 - random(10);
my.tilt = 0;
my.roll = 0;
my.z = 0;
}
}
return(0);
//
// effect(particle_ball,maxv(1,40*time_step),my.x,vector(0,0,5));
// vec_to_angle(my.pan, bounce);
// my.pan += 5 - random(10);
// my.tilt = 0;
// my.roll = 0;
// my.z = 0;
}
// function : release a ball when hit and explode when triggered by scan event or adds a new ball when collided
//-------------------------------------------------------------------------------------------
function release_ball()
{
if(event_type == EVENT_SCAN)
{
snd_play(explosion,100, 0);
effect(p_fountain,maxv(1,40*time_step),my.x,vector(0,0,5));
set (me, INVISIBLE);
ent_remove(my);
}
if(event_type == EVENT_IMPACT)
{
wait(-0.5);
tempbrick1[1] = my.x - 25;
tempbrick1[2] = my.y;
tempbrick1[3] = my.z;
ent_ball= ent_create("Bubble.mdl", vector(tempbrick1[1],tempbrick1[2],tempbrick1[3] ), move_ball); // create a new ball whet object is hit
ent_ball._ball=10;
ent_ball.ambient = 70;
wait(1);
}
return(0);
}
// function : moves the added ball
//--------------------------------------------------------------------------------------
action move_ball()
{
ballsInField+=1;
wait(1);
my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); // the object is sensitive to block and entity collisions
my.event = bounce_ball;
my._ball = 10;
while(1)
{
c_move(me,vector(30*time_step,0,0),nullvector,IGNORE_PASSABLE | GLIDE | IGNORE_FLAG2 | ACTIVATE_PUSH); // moves the ball
if(my.x < ent_catcher.x )
{
wait(1);
reset(my, SHOW);
ballsInField-=1;
break;
}
wait(1);
}
ent_remove(my);
}