• 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!

Hitting opponents, not me, but same object.

D

DiamondCraft

Guest
So im making a smash bros-ish game where you can have the same character but i dont want the onjects spawned that are used as projectiles, not the melee attacks, to hit the object (the player) that used the move to do the attack. i want to spawn the projectile on top of the original character and im doing this in Drag and Drop. Any suggestions? Thanks for the help.
 

samspade

Member
In other words you want to create an instance of object B with an instance of object A, and you want object B to be able to damage all instances of object A except for the one that created it?

Code:
///in object A
var object_b = instance_create...
with (object_b) {
    owner = other.id;
}

///in object B
with (object_a) {
    if (id != other.owner) {
        ///check for collision/damage etc
    }
}
Obviously, the above code isn't going to work exactly like that in your game, but the idea will. Save the instance id of the creating object as a variable in the created object and when doing collision checks, check the instance id against the saved variable before doing damage.

If that doesn't make sense the following might be helpful:
 
Top