playMaker

Author Topic: Array List Get Next loop  (Read 1122 times)

SawyerK

  • Junior Playmaker
  • **
  • Posts: 99
Array List Get Next loop
« on: March 10, 2023, 10:47:03 AM »
Hi!

A quick question.
Should I use "FINISHED" event on looping and iterating between "Array List Get Next" and "Array Add"?
It happens rarely that it seems like it didn't add certain objects into the array list, therefore saving then loading the game resets some of the items to their original starter position.
This doesn't happen all the time (never happened to me so I can't recreate the problem) but 3 different player reported that some of the items got reseted to their starter position.

My game's saving system is pretty straight forward.
There is an Array List with all the items in the world (710 gameobject as of now)
When save button is pressed I get these items from the Array List with "Array List Get Next" and store it to an Array variable then save it with "Copy Array to Pool"
I use "Smooth Save for Playmaker" asset for saving all the variables.

Loading the array is the same as above except I use "Copy Pool to Array" to load in all the variables at the end.

Could using "FINISHED" between "Array List Get Next" and "Array Add" cause this issue of rarely skipping certain items?

Thank you in advance!


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Array List Get Next loop
« Reply #1 on: March 11, 2023, 01:43:48 AM »
Hi.
The issue is not the FINISHED transition, but by default most of the time I use custom events if I use an action with an event.
For loop usually i use "Next" and "Done" this way i also can easily see that i have a loop action in that state.

But what you need to is :
add a bool variable on the "Array List Get Next" 'Reset'
in a state Before starting the loop set this bool to 'true' (not on the state it self or inside the loop)
this will make sure that the "Array List Get Next" will start from the start index.

i can see a 'resize' state which may be the cause.

for example 1st time the size = 6 then the next time its 8.
the "Array List Get Next" might continue instead of starting from the beginning