playMaker

Author Topic: HELP PLEASE ! Objects , variables and playerprefs .  (Read 3409 times)

markettounity

  • Playmaker Newbie
  • *
  • Posts: 30
HELP PLEASE ! Objects , variables and playerprefs .
« on: March 06, 2022, 05:27:03 AM »
Hello everyone !

I have a room with 200 cubes, each one has a "name" variable.

when I compile the game, in runtime, each cube has a menu with which you can change the name via an "input field". Then, using the "playerprefs" action, save the name entered in the input field.

The problem is that when I change the name to another of the 200 cubes the variation is not only on that but it changes the value on all the cubes.

I could solve it by setting a different "Key" for each cube for the "playerprefs", but it's a huge job.

How can I do to have a personalized save for each cube?

I looked up on the internet and maybe I found a solution in the "arrays", but I don't know how to use them.

Can you help me please?
Thanks a lot to everyone !!!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: HELP PLEASE ! Objects , variables and playerprefs .
« Reply #1 on: March 06, 2022, 10:08:03 AM »
Hi.
You could place all the cubes in a parent object and use get next child.

place fsm on the parent and setup like this :

State 1 :
"Get Next Child" (Store result in a variable and call it for example currentCube)
                        Set next transition to state 2 / Set Done Transition to State 3
State 2:
enable sequence (right click on empty space in the PM action window)

"Int Add" (do int add +1 set a variable)
"Build String" (set to 2 parts, part 1 set name you wish to use,
                    Set part 2 to the int variable (inside convert you can find the int variable)
"Set Fsm String" (set the result of the build string to the 'Key' variable on the cube)

Now each cube has a unique id and as long as you don't mix up the sequence of the cube during edit mode, they should always have the correct key

if the cube has children objects and get Next Child is getting those as well, you can add a checker in between like this :

Between state 1 and 2, add a state and set up like this :
enable sequence (right click on empty space in the PM action window)
Get Parent (Get parent from 'currentCube' and store in 'Parent' Variable)
Game Object Compare (set 'Parent' variable in Compare To)
                                  If equal Transition to state 2, if not transition back to state 1

markettounity

  • Playmaker Newbie
  • *
  • Posts: 30
Re: HELP PLEASE ! Objects , variables and playerprefs .
« Reply #2 on: March 06, 2022, 11:07:33 AM »
Thank you very much djaydino for helping.

Unfortunately it doesn't work.

when I try the program, the result in the "int add" action gives me ZERO and the "build string" action doesn't create any words ...

obviously also "set FSM string" leaves the "result" field empty ...

All the cubes have been placed in a parent object called "cubes" and keep in mind that each cube has "Input field" in a child object, so maybe the main FSM I have to put it in each cube and not in the parent "cubes"?

and About the State 3, should i leave it blank ?

Sorry if I ask you too many questions, but I don't have enough knowledge to succeed on my own ...

Thanks again !!
« Last Edit: March 06, 2022, 12:01:36 PM by markettounity »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: HELP PLEASE ! Objects , variables and playerprefs .
« Reply #3 on: March 07, 2022, 09:55:25 AM »
Hi.
Can you make some pictures of the setup

markettounity

  • Playmaker Newbie
  • *
  • Posts: 30
Re: HELP PLEASE ! Objects , variables and playerprefs .
« Reply #4 on: March 07, 2022, 12:29:03 PM »
sure !! here is the setup ...


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: HELP PLEASE ! Objects , variables and playerprefs .
« Reply #5 on: March 07, 2022, 08:39:43 PM »
Hi.
On state 1 on Get Next Child : loop event is correct Finished event is wrong
Create a new event (Done) and connect to finished event and replace FINISHED with Done.

State 2 :
There is no transition going back to state 1 (add a FINISHED event and Loop back to state 1)
on Set Fsm String the specify game object should target the 'currentArcade' variable.

Between state 1 and 2, add a state and set up like this :
enable sequence (right click on empty space in the PM action window)
Get Parent (Get parent from 'currentArcade' and store in 'Parent' Variable)
Game Object Compare (set 'Parent' variable in Compare To)
                                  If equal Transition to state 2, if not transition back to state 1

markettounity

  • Playmaker Newbie
  • *
  • Posts: 30
Re: HELP PLEASE ! Objects , variables and playerprefs .
« Reply #6 on: March 08, 2022, 06:49:53 AM »
Hi !!

First of all thank you for your help !

Unfortunately it still does not work, evidently I lack knowledge so I am unable to arrange variables and actions well ...

The problem is that in the action "Set FSM String" I cannot select the variable "current arcade" from state 1 ...

moreover the program seems to work, but only the arcade 1 changes, the others that have the key field of the action "Playerprefs" empty ...

this thing freaks me out ... is there maybe an alternative method to do this?

Here is the program modified with your suggestions ...

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: HELP PLEASE ! Objects , variables and playerprefs .
« Reply #7 on: March 08, 2022, 09:12:10 AM »
Hi.
in set fsm string you are still targeting a object (romfile)



This should Target the 'currentArcade' variable on the right side, press on the = sign then you can set variables to it

markettounity

  • Playmaker Newbie
  • *
  • Posts: 30
Re: HELP PLEASE ! Objects , variables and playerprefs .
« Reply #8 on: March 08, 2022, 09:41:00 AM »
i've changed it , but it doesn't works yet ....

i think that at this point is better for me to change the key of every gameobject one by one ...

It needs too much knowledgments that i don't have now ...  :(