[Solved] Apply events separately to each object

How do I…

Make same events apply to the same objects, but running on different instances?


I’m trying to make a “Smash Bros” like game, and to spare memory, events and lag, I came up with a multiplayer system using the same objects and a “ID” variable. However, there are some unexpected stuff happening, like damage being inflicted to the wrong object and the jump not working after jumping 2 times.

Also, I’m sorry for the long post, but I have no actual idea on how to explain this in a more summarized way

What is the expected result

I’m trying to make a “Smash Bros” like game, and to spare memory, events and lag, I came up with this system:

For instance, I have added 2 of the same player object into the scene, however, each one of them has a different variable named “ID”, which will identify which is player 1, which is 2, and so on (you can see a use of the variable in “Check for xxx input on player Player.Variable(id)”)

The expected result is, all of these actions should run separately on each player object, this way, if I create a 3rd player, I don’t need to copy paste all of the events for the player

What is the actual result

There’s 2 things that are making this system “not functional”:

  1. The jump system; These events define how I programmed it:

    When the player jumps and the variable “jumps” is bigger then 0, then jump and subtract 1 from the variable, and if you can’t jump while your variable jump is bigger then 0, then allow jumping again.
    And when the player is on the floor, set the “jumps” variable back to 2 (which is the default amount).
    However, when I jump 2 times with any player, I can’t jump anymore at all. (Note that this happens separately, when I jump 2 times with player 1 I can’t jump with player 1 anymore, but I can jump 2 times with player 2 (just so I can’t jump with player 2 anymore).

  2. Damaging

    A lot to explain, but I’ll try to keep it short. Basically, what all of this does, is check if the player is in collision with a object that inflicts damage. If it is, and the object ID is different from the player’s ID (so the player doesn’t take damage to it’s own “damage objects”, then inflict damage.
    However, at very specific times, in which I noted to be: when I inflict damage to the other player and create another “damage object”, then I get damaged to.

Related screenshots


Using this approach, the game works perfectly. However, considering I would have to repeat the same thing like, for each player, I think it really consumes the game’s memory, and I don’t consider it a optimized method. Is there any other method to replicate this in a more optimized manner? Thank you very much

1 Like

I’m not sure if this is still an issue but even if it’s not, this might help other people.

1st the jump problem. The issue is the on floor and trigger once. Trigger once behaves differently inside loops like for each object and instances. You can replace the for each with jumps of player object ≠ 2

The damage issue. When you add a bullet, the previous bullets are still in the object picked list. So, everytime you assign an ID, it changes all of the bullet IDs to the current ID.

You could make a subevent of the fire bullet event and use:

ID of object BulletName = 0 then ID of BulletName = ID of player object

I believe that will fix the 2 problems.

I think there is another issue. I’m not sure if you mentioned it. When you’re counting projectites you’re counting total in scene. To be fair, I think you need to count the projectiles per player. As is only 3 are allowed, so it’s first come first served.

I believe you’ll need to count them separately using ID of BulletObject equal ID of player object and number of picked BulletNane. I can’t test conditions for that right now. You might need to use a NOT condition and an AND / OR.

If you need any further help, let us know.

1 Like

Thank you very much! This solved all of the problems that I was having (as it seems so far)

I tried doing that, but as there are no BulletObjects to compare ID to, it just doesn’t shoot any bullets. But thanks for note-ing, I forgot to mention that in the post

1 Like

Sometimes that type of logic confuses me and I just need to use trial and error. I wish I didn’t. I need to practice more. Anyway, I tested the logic using the space bar but the logic should work.

The first condition counts the number of instances with matching IDs. Easy to understand.

The NOT (inverted) condition is the one that confuses me at times. If there’s no match it would normally be false but the NOT inverts it and makes it true. When there are matches it’s true and is made false by the NOT but since it’s part of the OR, the other condition triggers the action as long as there are less than 3 bullets.

1 Like

Wow! It worked just fine, thank you really much!
'bout the logic, I guess I’ll have to re-read that a 1000 times, but thanks for explaining it to me
Wish you the best

1 Like

Posting again, because I found another problem (I’m sorry)

This time is with the stamina
Basically, it is supposed to disappear once the player has reached the maximum amount of stamina possible. However, it just… Doesn’t disappear, and it also does not execute any of the other actions:

I suppose this happens because the other player instance already has the stamina maxed, so it only happens once? But I’m not sure, and I also don’t know how to filter this

I’m not sure I understand your concept. You start a timer, check the timer’s value but there’s no events to reset, stop or delete it once it gets started. Are these sub events of a for each object of player ?

1 Like

I decided to put together an example of one way to do it. It uses the sticker behavior on the stamina bar and the link actions under other actions. The sticker keeps the object in place until unstuck and the link creates a reference. You use the take into account condition to pick the linked objects. It’s under link in the other conditions. I decided to let the stamina build from zero but, you can set the default value to whatever you wish.

Try online, drag the players into the red zone to decrease their stamina.

Source files:

1 Like

This is probably closer to your concept. It used a timer to refill the stamina. I agree, I think the trigger once inside a loop was probably one of the issues. I replaced it with a Boolean. I don’t know how quickly you want the stamina to refill. I increased the value to make it more noticeable for testing. I like the idea of a timer because the events aren’t running on every frame but ultimately, it’s up to you. Use as much or as little of this code as you want.


Something like:



Oh, thank you so much! This literally solved all of the bugs, again!
I can’t thank you enough for helping me out so much : D

Oh and btw, just to have and idea, this is what the problem was, exactly:
(As you can see the stamina bar just doesn’t hide, and the player doesn’t flash)

But now it’s solved, thank you very much :smiley:

1 Like

You’re welcome. I like to help. I also like the challenge. I’m still learning myself.

1 Like