How do I use Repeat to spawn players

0 favourites
  • 3 posts
  • 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

    On Start of Layout > Unimportant stuff
        Repeat GlobalVariable times > Create Player at 750, (350 + (GlobalVariable * 150))[/code:3g058gpb]
    
    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.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • On Start of Layout > Unimportant stuff
        Repeat GlobalVariable times > Create Player at 750, (350 + (GlobalVariable * 150))[/code:uyww9chj]
    
    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:

    On Start of Layout > 
        Repeat 4 times > Create Player at 750, (350 + (4 * 150))[/code:uyww9chj]
    ...you "spawn" 4 players on the identical spot...
    
    Try:[code:uyww9chj]Repeat GlobalVariable times > Create Player at 750, (350 + (loopindex * 150))[/code:uyww9chj]
  • 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.

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