[SOLVED] Problem with multiple enemies

Hello everyone and thank you for opening this request for help :slight_smile:
The problem is this, I have a sprite that creates shots every second. now if I copy and paste this sprite (on the map, so the name remains the same), only 1 of the 2 (or more) works, the other does not shoot … Is there a way to allow me to create more sprites that follow the same rule? Or do I have to rewrite the actions for each duplicate sprite, making the game unnecessarily heavy?
Thanks a lot to everyone :slight_smile:

Hi!
It sounds like you need to use “For Each” type event, when you click plus icon to add events it will be there.
Depending on how you make the sprite shooting, (their X and Y position of the sprites?) it can work.
If you’re stuck feel free to insert the events screenshot of the sprite shooting.

2 Likes

Non funziona :frowning:
This is my event

Is “shot” scene timer? Try change it to object timer instead.

1 Like

This is better code that the first, with only one event !

1 Like

WRONG_CODE:

GOOD_CODE:

:wink:

1 Like

@reina now I try both your solution, both @frcreator777 solution…
For now, thank you! :slight_smile:

@frcreator777 Your solution works really well, and the bug I had before doesn’t show up, that if there was no object in the layer, the lasershot appeared in a random place… Thanks a lot :slight_smile:
@reina and thanks a lot to you too , that you solved the initial “my code” :slight_smile:

2 Likes

Happy to help you :wink:

2 Likes

sorry, I just noticed that if one the same bullet for multiple enemies, and for example at one corner, all move … So I have to create various bullets for each “configuration” of enemies? (like when they are rotated 90 °)

you must set one object variable (angle) on bullet, and do:

-for each object bullet, -if object variable (bullet)=0, -bullet collision with enemy, -trigger once, -add enemy angle to object variable bullet !!!

-object variable (bullet) is greater that 0, - set object variable (bullet) to the bullet angle !!!

1 Like

I don’t think I understand, sorry … I’ve been using Gdevelop for about 2 weeks :frowning:

1 Like

Its cool ! i will teach you the bases !

i will create one project for you when i have the time, for you see how you can create bullets on every enemy, and set sames direction/angle to enemy and bullets ! its what you want?

1 Like

You are really very kind! If you do I would really be able!

yes, lets me the time, i will help you ! i send you little basic example i have create for the moment, for give you idea for every projects :wink:

1 Like

This is my basic example for noob , look and study this , for the moment, i am creating bullets/enemy rotating example for you :wink: lets me 1 or 2 hours…

1 Like

This is the new code:

This is the new example project:

I hope that will help you ! If you have questions, ask me again :wink:

1 Like

First of all thanks for the help and for the time you spent for me!
Your projects have been very useful to me, I have learned a lot!
However, I think I was wrong to explain (I’m not English, so I have a bit of difficulty :frowning_face: ), my problem is that I have various stationary objects on the map (it’s a top-down game), placed at different angles, which they should shoot the bullet at the same angle they have
I attach photos :slight_smile: red marks where the bullets should go

Okay, its more simple ! me i am french and speak only little english, i traduice, and it’s good, i understand you;) ! i create project and send you that :wink:

1 Like