playMaker

Author Topic: PlayerPrefsx Bug? [SOLVED]  (Read 6296 times)

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
PlayerPrefsx Bug? [SOLVED]
« on: December 06, 2013, 07:36:37 PM »
I'm using the "PlayerPrefsx" Playmaker action, which is an add-on.

On trigger enter with a 3d object, I set a global Vector 3 key titled "CP" (for checkpoint). "Setting" and "getting" the key works fine.

On trigger enter for a separate 3d object, I set a global boolean key titled "PawnKey". It also works as expected.

However, if I try to access the Vector3 key  (using "get key") after setting the boolean key, the editor pauses and gives me this error:

Corrupt preference file for
UnityEngine.Debug:LogError(Object)
PlayerPrefsX:GetValue(String, List`1, ArrayType, Int32, Action`2) (at Assets/PlayMaker Custom Actions/PlayerPrefsx/PlayerPrefsX.cs:539)
PlayerPrefsX:GetFloatArray(String) (at Assets/PlayMaker Custom Actions/PlayerPrefsx/PlayerPrefsX.cs:430)
PlayerPrefsX:GetVector3(String) (at Assets/PlayMaker Custom Actions/PlayerPrefsx/PlayerPrefsX.cs:78)
HutongGames.PlayMaker.Actions.PlayerPrefsxGetValue:OnEnter() (at Assets/PlayMaker Custom Actions/PlayerPrefsx/PlayerPrefsxGetValue.cs:78)
HutongGames.PlayMaker.FsmState:OnEnter()
HutongGames.PlayMaker.Fsm:EnterState(FsmState)
HutongGames.PlayMaker.Fsm:SwitchState(FsmState)
HutongGames.PlayMaker.Fsm:UpdateStateChanges()
HutongGames.PlayMaker.Fsm:OnTriggerEnter(Collider)
PlayMakerTriggerEnter:OnTriggerEnter(Collider)


The two keys do not reference each other, and the FSMs don't interact with eachother. It seems that somehow, the boolean key is overriding, or corrupting, the vector 3 key, but I'm not able to understand why. have I found a bug or is there something I should be doing differently?

I'm greatly thankful for any guidance or direction that anyone can provide.

« Last Edit: January 22, 2014, 02:54:41 AM by Breadman »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PlayerPrefsx Bug?
« Reply #1 on: December 09, 2013, 02:21:06 PM »
Hi,

 ouch... that's a real nasty bug indeed, I am so braindead when it comes down to bytes that I fear tackling this actually :)

Could you narrow your bug into a simple repro project? if you can do that, that will help me tremendously so that I can get to the core of it right away ( I lack of time these days...)

bye,

 Jean

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: PlayerPrefsx Bug?
« Reply #2 on: December 09, 2013, 04:19:35 PM »
Hi Jean,

Glad to see you're back! Hope the trip went well.

I'll work on recreating that project for you as soon as possible.

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: PlayerPrefsx Bug?
« Reply #3 on: December 09, 2013, 05:13:54 PM »
Hi Jean,

I recreated the bug in a small project. The file is small (about 6mb), but still too large for the upload limit on the forum  ::) I'll forward the project to you in an email!

Thanks again for offering to take a look at this!
« Last Edit: December 09, 2013, 06:05:00 PM by Breadman »

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: PlayerPrefsx Bug?
« Reply #4 on: January 07, 2014, 12:24:53 AM »
Hi Jean,

Just curious if you've had any time to take a look at this bug? I was inactive for a while so I'm not sure if I might have missed something. I know you always have a ton on your plate, so I wouldn't be surprised if you've been busy solving bigger issues 8)


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PlayerPrefsx Bug?
« Reply #5 on: January 07, 2014, 04:22:25 AM »
Hi,

 Not had time no sorry. Have you sent me the sample repro? if not can you send it to me again? thanks.

 I have noted this on my todos, so now I won't forget.

Bye,

 Jean

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: PlayerPrefsx Bug?
« Reply #6 on: January 07, 2014, 01:19:13 PM »
Hi Jean,

No worries! I think I had sent it to you via email, I will resend it as well.

Thanks again!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PlayerPrefsx Bug?
« Reply #7 on: January 10, 2014, 09:20:32 AM »
Hi,

 I dont' see where you implemented the repro steps you mention, The project you sent me works just fine. Can you explain further what I need to do to repro your issue?

bye,

 Jean

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: PlayerPrefsx Bug?
« Reply #8 on: January 10, 2014, 11:34:54 AM »
Of course, let me see if I can explain.

The red and blue cubes assign a vector3 playerprefs key when touched. They flash white to let you know they've been triggered.

The pink sphere between the two cubes, when triggered, teleports the player to the last touched red or blue cube, by reading the vector3 key that was created. This part should work fine.

The golden cylinder, when touched, creates a random boolean playerprefs key. This key isn't used for anything, just created.

If you touch either cube and then touch the golden cylinder, and then touch the teleport sphere, you should find that the teleport sphere is no longer able to read the vector3 key that was created when you touched the cube, and the game will pause/crash. Something happens when that second key is created that causes an error.

I hope this helps! Thanks again for taking the time and energy to look at my issue! I really appreciate it :D  Let me know if I can be clearer or provide any other information.



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PlayerPrefsx Bug?
« Reply #9 on: January 14, 2014, 07:03:47 AM »
Hi,

 Ok, thanks, I'll work on that early next week, can you bump me then? currently travelling.

bye,

 Jean

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: PlayerPrefsx Bug?
« Reply #10 on: January 20, 2014, 11:23:40 AM »
Hi Jean,

Hope your travels are going/went well! Just bumping you on this as you requested.
 
Thanks again!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PlayerPrefsx Bug?
« Reply #11 on: January 22, 2014, 01:15:25 AM »
Hi,

 Everything is working fine. You simply have an empty string...

So your global variable "Just a Key" MUST have its value set to something other then an empty string and all will be well :)

The next version of this package will feature a check for this to warn about this.
 
bye,

 Jean

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: PlayerPrefsx Bug?
« Reply #12 on: January 22, 2014, 02:54:16 AM »
Jean,

Wow. I can't thank you enough for taking the time to look at my problem. Especially when it was such a simple fix. I can't believe that was all I needed to do.

Thank you soooo much!! My game is saved! (literally, I can save progress in-game now). I appreciate you spending time on this.  ;D

- Bread


Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: PlayerPrefsx Bug? [SOLVED]
« Reply #13 on: January 29, 2014, 02:42:38 AM »
I just wanted to add to this, for anyone who may be having the same issue and ending up here. I've been doing some testing and exploring the "playerprefsx" actions a little more thoroughly after Jean figured out what the issue was.

For your playerprefs to work properly, it's necessary that each new key is entirely unique.

Each key has a title. In the PlayMaker variables window, when your key is selected, this is the "Edit Variable" field. This is what prefs-related FMS will use to access the key. If you have multiple keys, they must have different names in the Edit Variable field.

In addition to the name of the key, the key has its own String (essentially a value). In the PlayMaker variables window, when your key is selected, this field is titled "string" and is directly below the "Edit Variable" field. The String component of the key must also be unique from all the other "string" components on other keys! To make this simple, I just set both the "edit variable" and the "string" to the same thing within one key.

Like so:

First Key: Edit variable = dinosaurkey
              String = dinosaurkey

Second Key: Edit variable = happykey
                  String = happykey

Notice how the variable and string fields may match inside of their own key, but do not conflict with the same fields inside other keys.

The following will also work:

First Key: Edit variable = dinosaurkey
              String = blahblahblah

Second Key: Edit variable = happykey
                  String = horray

Even if your FSMs end up assigning a new value to the key to store data(as mine do), it's essential that you still have both of these fields filled out with a unique value in the variables (or global variables) window. This way when your game starts, your keys have a "value", even if it does get overwritten. Unity will throw a fit if you ask it to overwrite an empty key, or a key that isn't 100% unique.

As a final note, typing a "0" into either the Edit Variable or String fields when editing a key will also make Unity unhappy.
« Last Edit: January 29, 2014, 02:44:38 AM by Breadman »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PlayerPrefsx Bug? [SOLVED]
« Reply #14 on: January 29, 2014, 02:57:48 AM »
Hi,

 Thanks for sharing, it's very important concepts indeed, and they are true even for regular use of playerprefs, not just with playerPrefsx

bye,

 Jean