• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM With but not self.

N

NoFontNL

Guest
Hi, this doesn't work:

with (obj_projectile(not self)) instance_destroy();

Can someone please give advise??

Thank you!
 

samspade

Member
Hi, this doesn't work:

with (obj_projectile(not self)) instance_destroy();

Can someone please give advise??

Thank you!
What are you trying to do? You can write the above as:

Code:
with (obj_projectile) {
    if (id != other.id) {
        instance_destroy();
    }
}
But that will destroy every instance of obj_projectile except for the calling instance of obj_projectile. Is that really what you're trying to do?
 
N

NoFontNL

Guest
I'm trying, when shooting a bullet (projectile) if it touches another projectile but it musn't detect itself, that it will destroy itself.

So:

Scenario:

Player 1 shoots bullet,
Player 2 shoots bullet,
Bullets connect,
Both of the bullets will get destroyed,
BUT the other bullets that don't touch another bullet will remain.

Hopefully this makes it clear ;) Please help. I'm stuck
 
M

Meowanator

Guest
Not sure if this is what you want, but in the obj_projectile's collision with obj_projectile event:

instance_destroy();
instance_destroy(other);
 

samspade

Member
I'm trying, when shooting a bullet (projectile) if it touches another projectile but it musn't detect itself, that it will destroy itself.

So:

Scenario:

Player 1 shoots bullet,
Player 2 shoots bullet,
Bullets connect,
Both of the bullets will get destroyed,
BUT the other bullets that don't touch another bullet will remain.

Hopefully this makes it clear ;) Please help. I'm stuck
If that is what you are going for, you definitely do not want to do what you initially suggested as that will destroy all bullets except the bullet which calls the code and if both bullets call the code it will likely destroy all bullets.

Meowantator's suggest is the simplest solution.
 
N

NoFontNL

Guest
BUT

Stupid of me, didn't thought about the collision event *facepalm*. Thank you! Is this also possible in GML code? I'm working on doing basically everything in code... Except for alarms and for collisions... But still, I want to know how it should work in code... Or isn't it possible?
 

samspade

Member
BUT

Stupid of me, didn't thought about the collision event *facepalm*. Thank you! Is this also possible in GML code? I'm working on doing basically everything in code... Except for alarms and for collisions... But still, I want to know how it should work in code... Or isn't it possible?
Meowantator's suggestion of putting:

instance_destroy();
instance_destroy(other);

in the projectile's collision event would do what you want.
 
Top