How do I assign health to spawned objects?

Get help using Construct 2

Post » Thu Aug 13, 2015 6:43 pm

Message: damon380 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hi,

I referred to this spawner example and am able to use this to use the wave method shown in the capx. flexible-wave-spawn-system-best-practices_t84475.

My second purpose is to store health in each spawned object and upon collision with another object, subtract by 1 and destroy when 0.

As per the example, I included an additional variable - health and maintained the health in the array e.g spawner/amount/type/health - "1;2;Yellow;1|1;1;Green;2|0;3;Red;1;3"

I created an instance variable on my enemy sprite - HealthX.
Under the as Spawn function, I set the health-local variable to the spawnobject and added another line to set healthx to health.

Separately, I have an event that upon collision, subtract 1 from healthX of the enemy sprite and one more event for e.g if pick instance with enemy.uid & healthX less than zero ->destroy the enemy sprite.

It doesnt seem to be right somehow. Can someone advise if there is a better method for this purely to detect collision of individual sprites for subtraction or if there is another topic which I can refer to?
B
10
S
3
G
1
Posts: 19
Reputation: 761

Post » Thu Aug 13, 2015 6:48 pm

what happens to the objects on collision? is first one delated or do they stay next to each other?

try to add everytick to collision detection.
B
11
S
4
Posts: 53
Reputation: 1,148

Post » Thu Aug 13, 2015 8:16 pm

collision detection is already check every tick
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Sun Aug 16, 2015 9:38 am

I have checked that the collision detection is enabled. Any other suggestions to look at?
B
10
S
3
G
1
Posts: 19
Reputation: 761

Post » Sun Aug 16, 2015 10:12 am

I'm curious to see the events that you used to have this problem... If you can post screenshot or capx....
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Sun Aug 16, 2015 2:23 pm

Message: damon380 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I basically edited the example that I mentioned earlier.. Do have a look here.. www.dropbox. com/s/6muo88q825bke5n/spawn_with_health.capx?dl=0 . I am trying to assign a health value e.g 1,2,3 to each sprite spawned.
B
10
S
3
G
1
Posts: 19
Reputation: 761

Post » Sun Aug 16, 2015 2:47 pm

Nothing seems happen in your example
Image Image
B
22
S
13
G
135
Posts: 871
Reputation: 70,320

Post » Sun Aug 16, 2015 3:30 pm

Like I said, I am trying to add health to the exising spawner example that I mentioned in the first post.In the original capx you will find that it will spawn objects with diff colors.
B
10
S
3
G
1
Posts: 19
Reputation: 761


Return to How do I....?

Who is online

Users browsing this forum: MikaelS, nahima, Shenkai the ssj and 23 guests