1. Hey! Guest! The 33rd GMC Jam will take place between May 23rd, 12:00 UTC (Friday noon) and May 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Hitting opponents, not me, but same object.

Discussion in 'Programming' started by DiamondCraft, Mar 14, 2019.

  1. DiamondCraft

    DiamondCraft Member

    Mar 13, 2019
    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.
  2. samspade

    samspade Member

    Feb 26, 2017
    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?

    ///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:

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice