Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
impact resolution - the entities are merging - #307286
01/28/10 12:22
01/28/10 12:22
Joined: Jan 2010
Posts: 44
Galati, Romania
CItrok Offline OP
Newbie
CItrok  Offline OP
Newbie

Joined: Jan 2010
Posts: 44
Galati, Romania
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);
}


}

Last edited by CItrok; 01/28/10 12:23.
Re: impact resolution - the entities are merging - [Re: CItrok] #307288
01/28/10 12:30
01/28/10 12:30
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
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.

Re: impact resolution - the entities are merging - [Re: DJBMASTER] #307289
01/28/10 12:33
01/28/10 12:33
Joined: Jan 2010
Posts: 44
Galati, Romania
CItrok Offline OP
Newbie
CItrok  Offline OP
Newbie

Joined: Jan 2010
Posts: 44
Galati, Romania
DJB MASTER Thanks a lot!!! It works!!!!

Have a good day!


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1