Multiple same objects instances - Only one do what I want.

Get help using Construct 2

Post » Sun Feb 12, 2017 6:35 pm

Hello. I have a project with a lot of ship fight together (Not controlled by the player). So I made 2 ships. One blue, and one red. If a blue one as Line of Sight to a red one. He shoot. Same thing for the red one.
But, Only one ship of the red and blue want to shot. I'am 100% sure that all the condition are verified for all the ship.

So I made some test in a new projet. I created 2 sprites. One red and one blue. And copy/pasted the red one and the blue one 3 times (so 6 objects in the scene). And with the following events :

- "Red Sprite" // has Line of sight to "Blue Sprite".
----- Every one second // Shoot

- "Blue Sprite" // has Line of sight to "Red Sprite".
----- Every one second // Shoot

But only one of the red sprite want to shot (The first instance I created of the red sprite). And only one of the blue sprite want to shot (The first instance too). And the 4 others don't do anything... I realy need your help. I'm totaly stuck with this...

This is strange because in my main project, all the objects instance respond to others events (like start fighting the other ship if he see it, or not). I having trouble only with the shooting system. Can you help me please ?
B
8
G
1
Posts: 6
Reputation: 439

Post » Sun Feb 12, 2017 7:37 pm

You just need to add a for each red sprite in the first event and a for each blue sprite in the second event.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Mon Feb 13, 2017 3:59 pm

Still don't work... Only the 2 first objects are shooting...

- For each "RedSprite"
--- Has line of Sight to "BlueSprite"
------ Every 1.0 seconds // Shoot

- For each "BlueSprite"
--- Has line of Sight to "RedSprite"
------ Every 1.0 seconds // Shoot
B
8
G
1
Posts: 6
Reputation: 439

Post » Mon Feb 13, 2017 4:10 pm

I just did a test level and it was fine for me. I guess only two of your sprites have line of sight or are in range.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Mon Feb 13, 2017 7:42 pm

Tryall wrote:Still don't work... Only the 2 first objects are shooting...

- For each "RedSprite"
--- Has line of Sight to "BlueSprite"
------ Every 1.0 seconds // Shoot


True. That can not work.

It is

Every 1.0 seconds
Has line of Sight to "BlueSprite"
For each "RedSprite"
___________ shoot

The 'for each' is not needed, but does not harm too.
But, now they just 'shoot'. Meaning, the direction can not be 'personal' in relation to the seen "BlueSprite"
I suppose that is not needed too, given that you did not elaborate about the way you 'shoot'.

If you really want help, plz make a simplified capx, upload it to a sharing service and share a link.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Feb 17, 2017 1:16 am

Well, That not working with my test project. But with my main project it's the case.. Well, thank you :)
B
8
G
1
Posts: 6
Reputation: 439


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi and 22 guests