0 Favourites

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

  • 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 ?

  • You just need to add a for each red sprite in the first event and a for each blue sprite in the second event.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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

  • 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.

  • 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.

  • Well, That not working with my test project. But with my main project it's the case.. Well, thank you

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
167 31,112
Ashley's avatar
Ashley Construct Team Founder
Unread hot topic
107 11,513
tgraupmann's avatar
tgraupmann
Unread hot topic
99 10,159
karshinkoff's avatar
karshinkoff