Different instances and different variable values

Get help using Construct 2

Post » Wed Mar 20, 2013 2:55 am

I have a variable for my enemy ship called FireRate. However, the issue right now is that every enemy ship fires at the same rate. How do I make it so that the enemy ships fire at different rates, meaning each different instance would have a different value for FireRate?

I have a For-Each condition, but I'm not sure how to tie it in with UID.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Wed Mar 20, 2013 7:08 am

The way you've done it (looking at your older .capx here) you pick the firerate for each enemy from a single instance of the enemy object. Add for each before your fire condition and it should fix it.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Mar 20, 2013 9:01 am

I'm not sure how to pick each single instance and then give that specific instance a value. Right now I'm going through each instance and giving every enemy the same value.

Excal2013-03-20 09:02:39
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Wed Mar 20, 2013 9:48 am

In the capx I was looking at it was done correctly:



It works, because the just created enemy is picked and any actions done to enemy objects are thus only applied to that particular enemy.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Mar 20, 2013 7:31 pm

Maybe it's just me, but they all seem to fire at the same rate?

SpaceGame.capx
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Wed Mar 20, 2013 8:10 pm

You still need to add the fix I posted in earlier post, add for each enemy before fire condition.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Wed Mar 20, 2013 8:28 pm

Do you mean like this?



Sorry, I'm not entirely sure what you mean. I'm still getting the same rate of fire on all of them :/
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Thu Mar 21, 2013 5:23 pm

I think I have to go through each particular instance after the enemies are created and set their fire rates that way, but separating the 'For Each' outside the 'Repeat' loop still causes them to all have the same fire rate because I'm not sure how to set the instance variable only for instances that haven't already been set.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Thu Mar 21, 2013 11:28 pm

Create ShipSprite > Set bullet speed: Random
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Fri Mar 22, 2013 1:31 am

I don't think that solves the problem, because in essence that's exactly what I have already done that isn't working.

I'm setting the firerate in the For-Each loop that creates each ship sprite.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Next

Return to How do I....?

Who is online

Users browsing this forum: Muini, Yahoo [Bot] and 30 guests