impact resolution - the entities are merging -

Posted By: CItrok

impact resolution - the entities are merging - - 01/28/10 12:22

I am experimenting using the code provided in tutorials.

I want to detect collision. I have used EVENT_IMPACT to detect the impact. However, I can see my two entities ( 2 planes - mig.mdl - from tutorial nr.10) are "merging" ( get one in the other) a lot until it is detected the impact. How to increase the resolution of detection? - if is possible? Bellow you can see the code.

I want the impact to be detected when the two entities are in contact.

Maybe is something wrong in my code? ( in this example I also can navigate with the joyistic and move the two entities)

///////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

///////////////////////////////////////////////////////////////////////////////////

ENTITY* ent1 = NULL;
ENTITY* ent2 = NULL;




function click_event2()
{



if(event_type == EVENT_IMPACT){

error("Impact model 2!!!");

}

}



function click_event1()
{


if(event_type == EVENT_IMPACT){



error("Impact model 1!!!");
}




}




action cub2()
{

my.emask = (ENABLE_IMPACT);



my.event = click_event2;
while (1)
{

if (key_q) c_move (my, vector(2*time_step , 0, 0), nullvector, GLIDE);
if (key_w) c_move (my, vector(-2*time_step , 0, 0), nullvector, GLIDE);

if (key_e) c_move (my, vector(0 , 2*time_step, 0), nullvector, GLIDE);
if (key_r) c_move (my, vector(0 , -2*time_step, 0), nullvector, GLIDE);


wait (1);
}

///////////////////////////////

}

action cub1()
{


my.emask = (ENABLE_IMPACT);
my.event = click_event1;

while (1)
{

if (key_s) c_move (my, vector(2*time_step , 0, 0), nullvector, GLIDE);
if (key_a) c_move (my, vector(-2*time_step , 0, 0), nullvector, GLIDE);

if (key_z) c_move (my, vector(0 , 2*time_step, 0), nullvector, GLIDE);
if (key_x) c_move (my, vector(0 , -2*time_step, 0), nullvector, GLIDE);


wait (1);
}

///////////////////////////////

}


function main()
{
video_mode = 9;
mouse_mode = 2;

level_load ("work10.wmb");
vec_set(camera.x,vector(-240, 280, -40)); // place the camera at x = -500, y = 0, z = 100

ent1=ent_create("mig.mdl", vector(100, 300, -70), cub1);
set(ent1,POLYGON);


ent2=ent_create("mig2.mdl", vector(-240, 200, -70), cub2);
set(ent2,POLYGON);

wait (2);


while(1)
{
camera.y -= joy_force.x;
camera.x += joy_force.y;
if (joy_4)camera.pan+=0.3;
if (joy_5)camera.pan-=0.3;
if (joy_3) camera.z += 1;
if (joy_2) camera.z -= 1;

if (joy_8) camera.tilt += 0.1;
if (joy_9) camera.tilt -= 0.1;


if (joy_1 && joy_2)
{
camera.x = 0;
camera.y = 0;
camera.z = 0;
}

mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;

wait(1);
}


}
Posted By: DJBMASTER

Re: impact resolution - the entities are merging - - 01/28/10 12:30

You probably have to change the collision hull of the entities. You can do this by calling 'c_setminxmax(entity_name)' after you've created the entities...
Code:
ent1=ent_create("mig.mdl", vector(100, 300, -70), cub1);
c_setminmax(ent1);
set(ent1,POLYGON);


ent2=ent_create("mig2.mdl", vector(-240, 200, -70), cub2);
c_setminmax(ent2);
set(ent2,POLYGON);



Also 'POLYGON' should only be used on 1 of the colliding entities. It's not really meant for moving entities either.
Posted By: CItrok

Re: impact resolution - the entities are merging - - 01/28/10 12:33

DJB MASTER Thanks a lot!!! It works!!!!

Have a good day!
© 2024 lite-C Forums