playMaker

Author Topic: Builtin Arrays with No Repeat.  (Read 869 times)

rizwanash

  • Junior Playmaker
  • **
  • Posts: 61
Builtin Arrays with No Repeat.
« on: May 24, 2021, 01:58:23 AM »
Hello guys,

I have a question regarding built-in arrays, what i am trying to achieve here is i have 1000 objects in a scene and i am adding all of them in an array variable (VoxelObjects) as gameobject in a global variable. In a Game manager FSM i am picking a random item from the array variable (VoxelObjects) but there are repeatable objects the action is picking up even if i select no repeat option.

i want to change color of all objects one by one but randomly and once all 1000 objects done i want to send the state to an empty so it wont loop.

i would appreciate any solution or guidance :)

Thanks in Advance.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Builtin Arrays with No Repeat.
« Reply #1 on: May 24, 2021, 10:12:23 AM »
Hi.
No repeat on randoms only don't repeat the same 2ce in a row.

If your array is not fixed number then you can do 1st a Get Array Length.

Then use 'Get Next Random Int' and on the int pool count use the result from the array length.

Then on the loop you need to use a int subtract (1) on the store next int since an index start from 0 not 1

then use array get and on the index use the Store next int variable

rizwanash

  • Junior Playmaker
  • **
  • Posts: 61
Re: Builtin Arrays with No Repeat.
« Reply #2 on: May 24, 2021, 05:07:31 PM »
Hey, Thanks for your reply on this.

I do have a fixed number of array items every level. every time i use random i get the same result no matter what i do. it cant even remove the item from the list.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Builtin Arrays with No Repeat.
« Reply #3 on: May 25, 2021, 06:41:24 AM »
Hi.
Use 'Get Next Random Int' (Ecosystem) instead of 'Array Get Random' and use the result from 'Get Next Random Int' as index to get it from the array.