Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, TipmyPip, OptimusPrime), 15,359 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Basic collision detection #130064
05/15/07 21:20
05/15/07 21:20
Joined: May 2007
Posts: 46
R
ribsribs Offline OP
Newbie
ribsribs  Offline OP
Newbie
R

Joined: May 2007
Posts: 46
Hi everybody!

I would like to ask if any of you gurus can explain me this one.
I think that the explanation would help many of us, if not, i'm a true newbie!
Heres the thing:

Basically i've got a spaceship, comets and asteroids.

I'm using c_move and c_setminmax to move and perform collision detection within the correct hull, and that works just fine.

If the spaceship collides with a comet, bum. But if the spaceship collides with an asteroid, the asteroid bounces. That's just the thing: How do i tell to the engine what is colliding with what?

I've read in some documentation something about .event and Event_type, but i also read that this functions work with ent_move or scan, and i'm using c_move.

My question is:

How to tell, in a specific action or model attached function, wich entity have collided with "me" ?


Thanks a lot in advance.

Re: Basic collision detection [Re: ribsribs] #130065
05/15/07 22:25
05/15/07 22:25
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
simple...
f.e. create names of entity like
entity* ship;
entity* rocket;
entity* asteroid;

then attach action to asteroid
if hit me ...
and you == rocket -> bum
and you == ship -> bounce etc.

or you may create defines...
define group,skill1;
define ships,1;
define rockets,2; etc
and then attach groups to entitys
my.group = ships;
my.group = rockets; etc
then in asteroid action...
if impact...
if you.group = ships -> bounce
if you.group = rockets -> bum

Last edited by tompo; 05/15/07 22:31.
Re: Basic collision detection [Re: tompo] #130066
05/15/07 22:32
05/15/07 22:32
Joined: May 2007
Posts: 46
R
ribsribs Offline OP
Newbie
ribsribs  Offline OP
Newbie
R

Joined: May 2007
Posts: 46
Thanks a lot for your time tompo.

Can you be more specific about "if hit me and you" ?
I'm no expert and i can't make that kind of deductions yet :S

Can you translate the "if hit me and you == rocket" into real example code?

Thanks a lot!


I've come with:

if(you==xlander && event_type==Event_impact)
{
Crash_Detect.string="COMET COLISION DETECTED";
}

Works great, but after the collision the if condition is always true, even when there's no colision at all.
A way to "reset" the "event_type"? the "you"?

Thanks.

Last edited by ribsribs; 05/15/07 23:29.
Re: Basic collision detection [Re: ribsribs] #130067
05/15/07 23:34
05/15/07 23:34
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
Read on events.

c_move modify the type of event when one was triggered on move.

So,
function myEvent()
{
if(event_type == event_entity)&&(you == rocket)
{
//bum bum.. bum
}
}

Now in the model action:

my.enable_entity = on;
my.event = myEvent;

Re: Basic collision detection [Re: demiGod] #130068
05/15/07 23:45
05/15/07 23:45
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
exacly this way as demiGod wrote..

if(event_type == event_entity)
{
if(you == rocket){bum bum;}
if(you == ship){(vec_to_angle(my.pan,BOUNCE);}
}

read about events in help: trigger, impact, entity, block, push...etc


Never say never.
Re: Basic collision detection [Re: tompo] #130069
05/16/07 17:52
05/16/07 17:52
Joined: May 2007
Posts: 46
R
ribsribs Offline OP
Newbie
ribsribs  Offline OP
Newbie
R

Joined: May 2007
Posts: 46
Working good, but the problem remains. I'm going to explain:

There is a spaceship, entity called xlander, set with "my.enable_entity = on;"

The comet is created at runtime, making a instance of the comet function, with ent_create.

In the comet function i have within a while(1):

if(event_type == event_entity)
{
if(you == landpad){Crash_Detect.string="LANDPAD DETECTED";}
if(you == xlander){Crash_Detect.string="COMET DETECTED";}
}


Works great until the first collision. When it collides for the first time, the message "COMET DETECTED" appears non-stop, even when the two entities aren't touching.

Any ideas ? Is there a way to tell it something like: "ok, i know the collision occured, check again please" ?

Thanks in advance.

Last edited by ribsribs; 05/16/07 17:53.
Re: Basic collision detection [Re: ribsribs] #130070
05/16/07 18:06
05/16/07 18:06
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
check something like this:
if "comet detected" is showing make colision with landpad,
if the string change to "landpad detected" and still be visible all the time it means that something is wrong with your text string function not this event

then use f.e. wait(16); crash_detect.visible = off;


Never say never.
Re: Basic collision detection [Re: tompo] #130071
05/16/07 20:01
05/16/07 20:01
Joined: May 2007
Posts: 46
R
ribsribs Offline OP
Newbie
ribsribs  Offline OP
Newbie
R

Joined: May 2007
Posts: 46
The problem is not the string. Even if i put there something like:

xlander.x-=1000;

The ship moves for ever, even with no colision at all, but only after the first colision, before that it's OK.

So i've come with "you=null", and the repeat forever issue is solved, but anytime that the comet is created again in it's origin (FAR away from the ship) the colision event occurs :S

Im not using the my.event directed to a external function, i'm using the colision detection in the comet function. Could that be the problem ?

Thanks again for your time.

Re: Basic collision detection [Re: ribsribs] #130072
05/16/07 20:16
05/16/07 20:16
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
becouse event function is similar to loop
so your ship will be moving forever as the string will be displaying all time
so you have to use in some function crash_detect.visible = off;
or in if (event_type == null){crash_detect.visible = off;}


Never say never.
Re: Basic collision detection [Re: tompo] #130073
05/16/07 21:16
05/16/07 21:16
Joined: May 2007
Posts: 46
R
ribsribs Offline OP
Newbie
ribsribs  Offline OP
Newbie
R

Joined: May 2007
Posts: 46
Jeez, i just can't get it right!
When the comet passes by, and get out the "spacedome" he is removed with ent_remove and proc_kill. Then, when i summon another one, the collision script emerges! I can't figure out why!!

Now i've tried to detect all the collisions from the spaceship action, like this:

move_mode=IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ACTIVATE_TRIGGER + GLIDE;
ent_move(vector((factor-(key_shift*300))*time,0,0),vector(0,0,Z_factor*time));

if(event_type == event_entity)
{
if(you == landpad){Crash_detect.string="LANDPAD";}
if(you == debris){Crash_detect.string="ASTEROID";}
if(you == cometa){Crash_detect.string="COMET";}
}

But now, when colliding with an asteroid, he detects a Comet!!
And when colliding with a comet, he detects nothing.
Landpad detects comet as well...
Really messy


Basically, 50 asteroids are created with ent_create, making instances of this function:

function asteroid()
{
my.enable_entity = on;

my.pan=random(360);
my.tilt=random(360);

c_setminmax(me);

while(1)
{
debris=my;

move_mode=glide+ignore_passable;
ent_move(vector(1,0,0),nullvector);

wait(1);
}

}
Hitting this asteroids would result in their bounce. Replacing the string thing in the colis detection will do the thing.

A single comet, a comet at once, is created occasionally by the same method.
When the program starts, there are no colision. I "summon" a comet, and no colision is detected until he actually hits the xlander (the ship).
After this, the comet is removed, and no colisions are detected.
But when i "summon" another comet, at that right instant, colision is detected. When the comet is EONS away from the ship.


I'm sorry if i'm beeing repetitive, but i guess i'm not explaining my problem right

By the way, is there any tutorial with the same situation? Like a tutorial in AUnlimited or such. I haven't find a specific one, maybe you know some?

I'm very grateful for the time that you spend posting here, thanks!

Last edited by ribsribs; 05/16/07 21:36.
Page 1 of 2 1 2

Gamestudio download | 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