I’m guessing the bullets go through the enemy and continue out the other side.
In which case, there are a number of scenarios/use cases to consider:
When a bullet collides with an enemy
When multiple bullets are in collision with an enemy
When a bullet collides with 2 or more enemies simultaneously
My inclination on this is to give each bullet a unique id when it’s created - the simplest one is just an increasing value. On the enemy, have a structure variable that records each bullet as it collides with it. Use the bullet id as the key, the value can be left blank.
When a bullet collides with an enemy, check whether the id exists as a child of that structure variable. If it doesn’t, add it as a child and cause damage to the enemy. And if the child already exists, do nothing.
I think that should cover all 3 scenarios/use cases
No need for an apology. You are better at communicating in English than a number of the native English speakers on this forum .
Yes, though I wouldn’t use the trigger once in the sub-subevent. It may not work the way you expect - I think it would just action once, and then never again until the scene is reloaded.
most likely I’m doing something wrong since I’m not very familiar with structure variables.
I searched the forum and was copying from an old post published by a user with the same problem as me
I still see the trigger once peeking at the bottom of the screen shot. That trigger once condition in the subevent has no other conditions in that event, so it will only ever trigger once during the game.
The check of the child exists in the structure is enough to ensure it only happens once for each enemy that is hit with the bullet. Remove that trigger once condition.
Also, do the collision between bullet and enemies first, then do the Repeat for each enemies as a subevent. It’s more efficient and faster for large numbers of objects.
If there are multiple live bullets, would he also need a for each bullet after the collision event? It’s confusing at times when a for…each is needed.
Collision with bullet
---- for each bullet
--------- for each enemy
The collision condition would “pick” any bullets that are in collision. So, that wouldn’t need a for…each before it but depending on what you do with the bullets, you might need a for…each for them.
I’m so sorry, I’m finding it difficult to apply this logic… I tried to search the net but I couldn’t find anything like it.
do you have an example or a guide to solve this problem?
thank you