How to get Instances of an object act independently

Get help using Construct 2

Post » Tue Jul 29, 2014 8:47 am

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:

Image
Image
Image
Image
Image
Image

red=player1
Image

Help would be much appreciated!
Thanks
genbatzu

//edit: bonusquestion: how can I get the player/enemies to "bump" from each other, if they collide?
Last edited by genbatzu on Tue Jul 29, 2014 1:01 pm, edited 2 times in total.
B
8
S
1
G
1
Posts: 29
Reputation: 735

Post » Tue Jul 29, 2014 9:50 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jul 29, 2014 9:56 am

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 =)
B
8
S
1
G
1
Posts: 29
Reputation: 735

Post » Tue Jul 29, 2014 10:44 am

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

:(
B
8
S
1
G
1
Posts: 29
Reputation: 735

Post » Tue Jul 29, 2014 1:00 pm

updated the OP, as I figured, that the problem is bigger than I thought
B
8
S
1
G
1
Posts: 29
Reputation: 735

Post » Tue Jul 29, 2014 1:05 pm

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

:D
You do not have the required permissions to view the files attached to this post.
B
8
Posts: 20
Reputation: 302

Post » Tue Jul 29, 2014 1:55 pm

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
Image

the result after reverting the changes
Image



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.

Image

Image
B
8
S
1
G
1
Posts: 29
Reputation: 735

Post » Wed Jul 30, 2014 6:22 am

bump for the shooting problem :)
B
8
S
1
G
1
Posts: 29
Reputation: 735


Return to How do I....?

Who is online

Users browsing this forum: Kin and 41 guests