Hitting multiple enemies with the same bullet! Object variables are awesome!

Hello everyone!

Gonna share something else i learned along the way,

This time its about using Object Variables as a sort of tagging system so you can hit multiple enemies with just one bullet or “pierce” through them while doing damage.

The moment i learned how to use object variables to control the Actions and Conditions better and make them do exactly what i had in mind, i started using them for everything…

This is the new video!

This is the old video:

Dont worry about the length of the video, the cool info is right at the start!
Hope you can get something out of this and learn from it.

I know i dont always do the best job of explaining myself but just bare with me a little and ill get the hang of it :slight_smile:

I was kinda annoyed at myself for doing such a poor job of explaining something so cool at i found so useful and use everyday… that i tried again and made a new video.

Hope you can get something out of the new one!

And if you find any of this stuff helpful, let me know <3



Right mouse button to cast special weapon
Mouse scroll button to change level of weapon
Hold left and right mouse button to change weapon

Get shield at level 3 then switch to different weapon
For example axe at level 3 and you can damage enemies by shields and Axe at once multiple enemies

Same with cross

Knife at level 3 hold RMB for a few secs

Whole magic to it is not as we see in every single tutorial to damage object while it is in collision with something since we need to use trigger once for it and so you damage it only once

You make variable for enemy that have 2 states for example boolean variable (i still went with number variables)

Enemy variable GettingDamage is false
Enemy is in collision with weapon
Trigger once

Change enemy variable GettingDamage to TRUE
Change enemy variable HP subtract 10
Wait 0,2 sec
Change enemy variable GettingDamage to FALSE

This kinda works the exact same way as with what i call “object tagging” with object variables… but the flaw is that its time based, so this is how youd do it for a damaging effect that is in contact with an enemy for extended periods and you still want it to do damage periodically. Like your spinning weapon example.

So for instance, if your using a bullet instead of “Weapon” in your example, and you shot 2 that ended up on top of each other and hit the same enemy, ONLY 1 will do damage.

If you give each attack or bullet a destinct ID or Variable like my example of the piercing fireball, you could have as many attacks hitting as many enemies that it will always work as intended.

Trigger once can be really tricky, avoid using it on things its not necessary…

For example, a Damage Over Time, if the condition of the damage has “Trigger Once” and by chance 2 DoTs tick at the same time, no more DoTs will come trough untill you reset the whole thing.

Also… im not picking on you, but you kinda contradict yourself… you say:

And then your example is literally this, just with the added stept of the variable, wich is just another take on what i was trying to explain but without the timer or restrictions that come with “Trigger Once”.

You did not understand what i meant
Every single damage tutorial i see is about when object A is touching object B then do it with trigger once to not spam hp subtraction and cut yourself out of multi object damage and damage over time

That is what i meant

My idea was to do DoT
But you can cast shields in my example and check can you damage one enemy with two shields at once
I am pretty sure you can since i distributed instance variables to them

I could simply skip trigger once by going with number variables
For example enemy variable CanTakeDamage = 0
Action subtract 10 from HP of enemy
Change CanTakeDamage variable of enemy ADD 1

Another event
Enemy variable CanTakeDamage is equal or higher than 1

Change CanTakeDamage variable of enemy set to 0

And i could spam every single frame damage to enemy

MANY MANY WAYS of doing it even based on animation
I once were using object with to animations instead of boolean variable cause i did not know how variables work
And few months later i seen person doing exact same thing with animations just he had object with 10 animations
Other ppl do that with opacity since you can detect exact opacity of object
Now i am using real time instead of timers where i simply mod times per sec to loop around some number for example DigitalClock10 loops from 0 to 9 so 10 secs loop for each second
And so i do not need to spam timers for everything

And instead i simply have one timer which is actually real world time which runs is accessible at any time (actually it is time of your device)

And simply perform action if something is equal to current value

And so each 10 sec i am distributing exp to farmland and trees

I can go with RandomInRange instead of just giving them strict number to check

Again i am explaining this because what you describe and i with our damage system
There are tons of ways to do it
And in most cases we are shown only one very poor method of applying damage
Which works but only until you want to do some fancy stuff

1 Like

Ahh cool, i get you now :slight_smile:

Let me know if you want some help making some sort of system for your game, i got plenty cool stuff to talk about that iv figured out along the way! :slight_smile:

My problems are with logic not with how to do something in gdevelop

Wanna help someone start coming to gdevelop discord
A lot ppl need there help
And if you have some practical knowledge you consider helpful to ppl why not start making examples?