playMaker

Author Topic: (SOLVED)how to get FSM Array  (Read 1501 times)

SawyerK

  • Junior Playmaker
  • **
  • Posts: 92
(SOLVED)how to get FSM Array
« on: June 26, 2021, 02:11:44 PM »
Its might be the most simplest thing ever but i cant seem to wrap my head around how this works.
 How do i connect the Playmaker Array List Proxy to a FSM Array variable, so that i can use the Get FSM Array to store the values for saving the gameobjects position on save/load game?

« Last Edit: July 18, 2021, 12:05:41 PM by SawyerK »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: how to get FSM Array
« Reply #1 on: June 28, 2021, 08:35:49 AM »
Hi.
Array List and array are 2 separate things.

for Array List you don't need to use get fsm array.

But you need to use a Reference Name and target the gameobject where the array list is on.

If you want to 'Convert' to an array then you need to loop thru the array list and use Array Add to store it to an array.

SawyerK

  • Junior Playmaker
  • **
  • Posts: 92
Re: how to get FSM Array
« Reply #2 on: June 28, 2021, 04:33:14 PM »
Thank you for the help!

How would you save a variable number of gameobjects position and rotation? My problem is that it's not a constant number of objects, items get added when the player buys something and or gets destroyed when for example food gets eaten or cargo delivered. The Array list's number of items gets updated when the player opens the menu. Do i have to always add and remove items form this array by looping through the array every time the player want to save the game?

Or would you just add an FSM to every object to save it's location and rotation when the player hits the save button? I dont know how this would affect FPS when there is hundreds of objects.

This is the last thing (Save/Load Game) that needs to be done before i can release my game on Steam :D

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: how to get FSM Array
« Reply #3 on: June 29, 2021, 07:22:35 AM »
Hi.
The best way is to use the "Easy Save"  asset and get the 'Array Maker Easy Save' package from the ecosystem.

i would use several array lists on a main object.
1 for rotation, 1 for position, 1 for GameObject, 1 for reference (name/id)
and possibly more for color/material/etc.

Then if a new object added place it in that list.
to update the position you can use for example 'Array List Contains' and you can use that on the GameOject array list or on the Reference array list.
and store the index.
then use the index to get/set the data for the other arrays.

To save you might not be able to save the Game Objects them self.
But you  can use the 'reference' array list (string reference or int Id) to know what object and then create them on restarting the game.


SawyerK

  • Junior Playmaker
  • **
  • Posts: 92
Re: how to get FSM Array
« Reply #4 on: June 29, 2021, 09:55:33 AM »
Thank you for the Reply!

Well i guess i'm gonna be here for a long time cause i just don't understand how this array list stuff works. xD Like when items get deleted, it deletes it in the array list as well so the index gonna change. for example.: object at index 1 gets deleted. buy a couple of items, these get added to the list, then load the game back to the original state, but the indexes are all shifted because of the deleted and added items, and when you load in, the objects get another objects (position,rotation,size,name ect)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: how to get FSM Array
« Reply #5 on: June 29, 2021, 08:54:37 PM »
Hi.
If you delete an object.

Do Array list contains (gameobject) and get the index.

Then use Array list Remove At for each list you have (position,rotation,size,name etc)

Best is to make a test scene and play around with it to understand how it works