How do I use Repeat to spawn players

Get help using Construct 2

Post » Mon Sep 28, 2015 1:50 am

I'm making a mockup for an RPG. Currently I have a Slider to select how many players are in a party (just for testing). I have the slider set a Global Variable to the Slider's Value. Then, when I load the Layout that should spawn the players, I have
Code: Select all
On Start of Layout > Unimportant stuff
    Repeat GlobalVariable times > Create Player at 750, (350 + (GlobalVariable * 150))


That should mean that if I set my slider to 4, it would spawn 4 players, each with lower and lower y coords. However It seems to only spawn the last one.

My set up is a bit more complex than that, and I am getting other problems, but I'll leave those out unless someone thinks the problem lies elsewhere.
B
4
Posts: 2
Reputation: 204

Post » Mon Sep 28, 2015 2:16 am

Frei wrote:
Code: Select all
On Start of Layout > Unimportant stuff
    Repeat GlobalVariable times > Create Player at 750, (350 + (GlobalVariable * 150))


That should mean that if I set my slider to 4, it would spawn 4 players, each with lower and lower y coords. However It seems to only spawn the last one.



so..you code looks like:
Code: Select all
On Start of Layout >
    Repeat 4 times > Create Player at 750, (350 + (4 * 150))

...you "spawn" 4 players on the identical spot...

Try:
Code: Select all
Repeat GlobalVariable times > Create Player at 750, (350 + (loopindex * 150))
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Mon Sep 28, 2015 2:43 am

Haha, yes, I just realized I hadn't accounted for multiplying a 'count' variable, but that loopindex will sure come in handy. Those simple mistakes are painful.

Thanks for having a look. I also realized the sources of my other problems.
B
4
Posts: 2
Reputation: 204


Return to How do I....?

Who is online

Users browsing this forum: jezjones24 and 13 guests