Hitbox for each projectile

Hey guys
how can I create a hitbox for each projectile that follows its resize and elimination.
if two projectiles are launched they are resized or eliminated at the same time.
I tried adding a boolean variable but it doesn’t seem to change
some idea?

Filter the projectile first, then use the “Repeat for each instance of bullet8” - move the repeat event to a child of the boolean check condition, have the animation check conditions sub-events of the repeat and remove those trigger once conditions:

1 Like


is this what you mean? if I launch two bullet8s together they still continue to resize and delete together.
I had to fix the stop shaking event because it was controlled by the boolean variable and never stopped vibrating


in the end I managed to manage it this way using the link to bullet8 and that’s how it seems to go

1 Like


Now I have another problem…
the “meleehitbox” item is created on all melee weapons and in explosions.
how can I manage the damage for each weapon with projectiles I used a text variable for each projectile but in this case it doesn’t seem to work.
I’ll give you an example:

grenade removes 100 hp
knife removes 20 hp

if the enemy collides with the “meleehitbox” of a grenade, 100 hp points are deducted and if he is immediately hit with the knife and the enemy collides with the grenade again, 100 but not 20 are deducted

Does the damage get inflicted if it’s knife only? If so, then it could be a timing issue, where the grenade conditions are met a frame (or more) before the knife conditions are met. This would cause the Damage boolean to be set on the enemy, and prevent the knife damage from being inflicted.

In which case, the solution may be to create multiple boolean variables on the enemy for each weapon that can cause damage, to keep track if it’s already been hit by each weapon. The simplest would be to convert the current Damage variable into a structure, and add a boolean child to the structure for each of the weapons, using the weapon name as the key/child name.

I’ve already created a structure and added a damage value for each weapon


I don’t think this is the problem…
the problem arises when the enemy finds itself in collision with a fire for example where a “meleeattack” damage object is created to manage the collision and the damage value;
the player continues to damage it with a knife where the same “meleeattack” object is always created but not the damage of the knife but of the fire is taken into consideration

I tried inserting a text variable or changing the animations of the “meleehitbox” object but nothing changes.

maybe the only way is to create a different hitbox for each weapon

The damage structure you screen snipped is a variable (most likely global) that has the damage amount inflicted by a wepon.

What I’m suggesting is a structure on the nemici objects, that keeps track of which weapon has just hit the enemy.

Currently the nemici.Damage variable only indicates that the nemici was hit and damaged by a weapon. It does not indicate which weapon. So when a grenade damages the nemici, that Damage boolean is set to true. But then if a knife attack follows immediately after, it doesn’t cause damage because nemici.Damage is still set to true.


So this:

image

becomes 2 events:

  • The first event checks if the variable Damage.arma15 of nemici is false, and then does the first subevent of that screen shot.
  • The second event, on the same level as the first one, checks if Damage.bullet8 of nemici is false, and then does the second subevent of that screen shot.

And you’ll have to do similar for all other weapons.

1 Like

I created a structure for each enemy that takes into account which weapon it hits


now what happens is that all boolean variables are set to true when the melee attack object hits, creating multiple damage.
in the group called “damageobject” there are various projectiles and melee attacks.
the problem now is linking the item to each weapon, I tried to use but the link between the 2 objects is not taken into consideration

This is a typical melee attack management event

Yes, because you are setting the Damage.<weapon> to true no matter what the weapon is.

If those last 2 events in the screen shot only set the boolean variable, then I’d suggest replacing them with with the one event:

image

But, if those last 2 events in the screen snip do different things, then another approach has to be taken.


Also, put these events outside of the repeat for each object loops. They should be at the same level as the top event in the screen shot.

1 Like

Ok, yes each weapon creates different damage and knockback. what would you suggest to do to link the collision object to the weapons?

If the structures of the actions are the same, but the only differences are values (amount of damage and knockback), then those values can be put into a structure. You have already done this for the weapon damage, and you can do the same with knockback.

Then you can have one set of events:


Aren’t you doing that already (as per one of the screen snips in a previous post)? Or is there something I’m missing?

1 Like


is damage object taken from the object group? in this case the projectiles are also taken into consideration in the variable

for the management of damage and backlash


the values are stored in a scene variable and not in the enemy variables
I need to leave the damage values there because they will be increased with powerups during the game and will then be saved from one scene to another


if I wanted to go back to the previous point, there is another way to understand which of the weapons activates the Boolean variable.
there are only 5 melee attack weapons and I’m getting confused in managing it in the structure.
Unfortunately I don’t understand how to manage the other conditions, I prefer to manage them individually

If you want to keep the events as they are in the screen snip, you’ll need to add a condition that checks that the weapon that is causing the damage matches the boolean being set.

So for this event:

image

You’ll need to add the compare 2 strings condition, and check that the danni object’s name is “coltello”. If you don’t add this condition, then Damage.coltello will be set to true if it’s currently false, no matter what weapon is causing the damage.

1 Like

I’m sorry if I reply at long intervals but I’m quite busy with work in this period.
what should I compare between the two expressions?
I’m not very practical
Thank you Jeroen

I would use danni.ObjectName() as one parameter, and "coltello" as the other parameter. You only want to set the boolean value of the Damage structure child that matches the weapon name.