How to get Instances of an object act independently

0 favourites
  • 8 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I restructure my question:

    I spawn an Object multiple times and want that each of them act independently, meaning they shoot when they see me, and not if any of them see me, they have their own HP, which spawns on them and not on the first created of this object.

    basically, what I need is a much more handy form of this:

    After 10 Seconds Spawn Enemy1 with HP1 on top of them, if Enemy1 is in LineOfsight of Player1 (or Player2) shoot at them

    After 10 Seconds Spawn Enemy2 with HP2 on top of them, if Enemy2 is in LineOfsight of Player1 (or Player2) shoot at them

    After 10 Seconds Spawn Enemy3 with HP3 on top of them, if Enemy3 is in LineOfsight of Player1 (or Player2) shoot at them

    After 10 Seconds Spawn Enemy4 with HP4 on top of them, if Enemy4 is in LineOfsight of Player1 (or Player2) shoot at them




    After 10 Seconds Spawn EnemyN with HPN on top of them, if EnemyN is in LineOfsight of Player1 (or Player2) shoot at them


    original text:

    Hi guys,

    first of all I dunno how I should'Ve put that into the topic title, so here it's a bit more in detail:

    I spawn an enemy1 sprite all 10s and this enemy1 sprite should have an HP bar and a line of sight object. However, if I align the HPbar it always aligns to the first instance of enemy1. so all other enemies, spawned after him have no HP bar. Except if the enemy1 with the HP bar dies, then the HP bar spawns on top of the next Enemy1

    Question: How can I get the HP bar to spawn on each Enemy1, when the Enemy1 spawns, stay there till as long as it has HP and then gets destroyed with the enemy1.

    here are all related events and a gif to demonstrate my problem:


    Help would be much appreciated!



    //edit: bonusquestion: how can I get the player/enemies to "bump" from each other, if they collide?

  • I guess in this case using containers would be helpfull..

    put the lifebar in the container with the enemy and it will spawn with it..

    Also instead of setting position every tick it might be better to use the pin behaviour..

  • Hi LittleStain,

    thank you for the reply!

    As container and pin behaviour are new to me, I'll do a little research on them now =)

  • hmm.. so I had a look, but it's not working as I hoped it is.

    adding the hp_bar_enemy1 with enemy1 in a container, doesn't do anything

    adding the PIN behaviour to hp_bar_enemy1 still pins every hp_bar_enemy1 to the first enemy1


  • updated the OP, as I figured, that the problem is bigger than I thought

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Dude, i don't know if this will help, but anyway, you should use "On Created" to pin the hpbar to each spawned enemy.

    Here an example of that, try to adapt to your needs

  • Hi blinkn,

    it works partially, thank you.

    something weird happend ôo after I've tried your solution, with the pinned object i reverted the changes, because of the hp_bar_enemy1 positioning (1st gif) and now it works as I wanted it to be (2nd gif)

    the solution with hp_bar_enemy1 pinned to enemy1

    the result after reverting the changes

    thank you very much for your help, it looks like I had something wrong and fixed it unintentionally while reverting. going to look for my mistake now.

    However, 1 Problem remains, only the first Line of Sight triggers a shoot_at_player1_command and it triggers the shoot command for all enemies and not individual.

  • bump for the shooting problem

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)