How do I use an array to set the value on multiple variables?

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • So I'm working on a game where every time you play it, it has random controls. I'm using variables to determine what keys are selected, but I don't want one key to be used for two things, so I'm trying to see if I can use an array to make sure there's no overlap, however, I'm an amateur. If there's a simpler way to not have 2 or more variables be the same with or without arrays, I'd really appreciate it.

  • Did not fully understand the post but in general if you want non repeating values you can use a Permutation table in Advanced Random this creates randomly shuffled string of numbers which can be useful. Or yes you can use an Array fill it with the values and delete the row each time something is assigned.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Arrays are often overrated.

    To pick two non-repeating random values you need the AdvancedRandom plugin:

    You can also do this with object instances. Say, if you want to give the player 2 random keys out of 10, you can place all 10 key sprites on the layout (somewhere off-screen). Then on start of the layout pick two random key instances and destroy the remaining ones.

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