[SOLVED]Problem with multiple enemies


#1

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:


#2

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.


#3

Non funziona :frowning:
This is my event


#4

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


#6

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

https://mega.nz/#!VthwRQ6b!p7z6eDHrF4o1onBjmIRKEhwanb6RPM0RhbrxFncOXKg


#7

WRONG_CODE:

GOOD_CODE:

:wink:


#8

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


#9

@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:
@cat and thanks a lot to you too , that you solved the initial “my code” :slight_smile:


#10

Happy to help you :wink:


#11

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 °)


#12

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 !!!


#13

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


#14

Its cool ! i will teach you the bases !


#15

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?


#16

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


#17

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:


#18

https://mega.nz/#!dxYT2IiC!y0Tnv9nczbqOgg2PRWeY9_bxw-FB6QplpoiF6z55N18

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…


#19

This is the new code:

This is the new example project:
https://mega.nz/#!Vl5BiCjK!9P0M-OMHC5Qu8azrbN4caqGwHjklFDLNH_uDShGEgg8

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


#20

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


#21

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: