Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: nabilfx on March 02, 2019, 02:08:24 PM

Title: It is possible to save playmaker state?[SOLVED]
Post by: nabilfx on March 02, 2019, 02:08:24 PM
I need to save the values the playmaker image property, after close the app. Then when open again it stil where it was. How can i do that? heres the example.
Title: Re: Save values after close app
Post by: djaydino on March 03, 2019, 05:57:40 AM
Hi.
You can use playerprefs to load/save (int, float or string) values or you can get the Easy save asset which has a lot more options and variables to be able to save.

you can save when you change something, or you can use the Application Quit Event (see image below )

(https://i.imgur.com/HRCAvwam.png)

And save from there (The event will be triggered when application is closed)
Title: Re: Save values after close app
Post by: djaydino on March 03, 2019, 06:02:33 AM
Btw,
you could use "Activate Component" from the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) instead of the Set Property.

You should always try to avoid Get/Set Properties :)
Title: Re: Save values after close app
Post by: nabilfx on March 03, 2019, 09:23:46 AM
It is possible to save playmaker state? on quit, then reload it on start?
Title: Re: It is possible to save playmaker state?
Post by: djaydino on March 04, 2019, 01:07:43 AM
Hi.
Not directly, but you might be able to save the string by using 'Get Fsm State'
Then when starting the game use "GoToStateByName" (you can find it on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181))to set the current state on the fsm.

just a mention, start state will always be triggered, so you might want to separate it so that it would do nothing.
But that depends on your setup.

Title: Re: It is possible to save playmaker state?
Post by: nabilfx on March 04, 2019, 10:55:49 AM
If i put the State 2 at State name it works.
But how can i put anothe State, when the app start again?
It should be the State that suppose to be save at quit app

here attach pic with the exemple
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on March 04, 2019, 11:17:58 AM
Is not possible to save the FSM, in app momory on Quit?  without SQL
Title: Re: It is possible to save playmaker state?
Post by: djaydino on March 04, 2019, 05:30:56 PM
Hi.
Not that i know off.

try this :

on each state with the button also have a 'PlayerPrefs Set String' and in the value, place the name of the state where the action is in.
on the 'Key' use the same name on all the actions. (for example "ButtonState")

in the salvar fsm on the start state :
1st have a "PlayerPrefs Has Key" (this is to check if something has been saved already)
and Set a false event to a new state

The new state call it (for example) Create save.
have a 'PlayerPrefs Set String' and place the state name that you want for the button when used for the 1st time (for example "State 3")
add a FINISHED Transition and point it back to the start state.

on the start state (below the "PlayerPrefs Has Key")
also have "PlayerPrefs Get String" (to get the saved value)

Below that, use the "Go To State By Name" and use the string variable you got fro the "PlayerPrefs Get String" action.

Let me know if you got it to work, else i will see if i can make a sample scene.
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on March 04, 2019, 06:07:45 PM
I can not make it work, can you do a sample scene please.
Title: Re: It is possible to save playmaker state?
Post by: djaydino on March 13, 2019, 03:25:09 AM
Hi.
Here is a sample (Attachment below).

The rotating state just has some wait actions and when you stop the game, the current state will be stored.

Then when you start to play, the rotating states will start from the state it was.
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on March 13, 2019, 10:47:47 AM
Jean, it works, thank you very much.
Title: Re: It is possible to save playmaker state?
Post by: djaydino on March 13, 2019, 07:25:07 PM
Hi.
I'm Not jean, but i am happy you got it to work :D
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on March 26, 2019, 05:02:37 PM
djaydino, the sample you send works great. I have a vuforia playmaker, on image found and lost. I would like to move the (Rotating States) with vuforia playmaker, on image found and lost, let said i stop in the state 4, doing image found and lost, then save the current state in the (Rotating States) as is it now. How can i connect the vuforia playmaker state, to move on an on through the (Rotating States), them on quit, and start again i will continue from there, doing the same on image found and lost.
Title: Re: It is possible to save playmaker state?
Post by: djaydino on March 26, 2019, 06:29:26 PM
Hi.
Sorry i have never used vuforia, maybe you could show me the fsm/actions on a video or images.
So that i have an idea how it works :)
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on March 26, 2019, 10:18:10 PM
I did it, i figure out thanks, one more thing, is possible to save the state without the press of a buttom with aplication quit? Just by closing the app?
Title: Re: It is possible to save playmaker state?
Post by: djaydino on March 27, 2019, 08:56:57 AM
Hi, yes

In 'transition events/System Events/' you can find the transition "APPLICATION QUIT"
Point this to a state where you save data.
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on March 28, 2019, 12:57:05 AM
I did this fidelity card that release one event every time vuforia read a image target in another celular screen, the problem now is if some body has a screen recorder at the time of scanning, there is no security in the system. It is possible to make a permission like a buttom in the celular phone that has the inage target, to confirm the scanning? So there is no chance to fraud. Is it possible to comunicate to another app with playmaker, with a press of a button to release the confirmation of the scan?
heres the link
Title: Re: It is possible to save playmaker state?
Post by: djaydino on March 28, 2019, 05:18:37 AM
Hi.
Not sure what you mean?
Should a qr code only be able to be scanned once?

if so, when you scan, does it give a string variable?
if so, store them in an array and when scanning check if array contains the string.

It is also best to start a new topic, as its a bit off topic from the subject :)
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on March 28, 2019, 05:28:15 AM
Hi,

 you need a server side system that handle the usage of qr code.

 everytime you issue a qrcode, you save in your database the reference to that qrcode and a flag that is false by default. When it's used ( that is, when the purpose of the qrcode is fullfilled), you raise that flag to true

your other app can check against this database weather this qrcode is ok or not.


that is, it's if I understood your issue properly :)

Bye,

 Jean
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on March 28, 2019, 08:05:53 AM
is an image target, can use any image, always gonna be that image, is it possible to make a simple example? To confirm in the other cellphone app with playmaker buttom.
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on March 29, 2019, 02:15:47 AM
Hi,

Do you mean you want to reuse qrcode? that's not a good idea, qrcode should be computer generated and always be unique if your intend is single use. I read from your post that you use vuforia, which leads me to believe you are simply using vuforia image target recognition, which is not like reading a qrcode, if so, this is not ideal, and you should use a real qrcode reader, and generate unique qrcode for each needs, and associate that qrcode with the actual person account id from your app.

If you want to make a fidelity card, you need a user management system to begin with, do you have one. Can user log in to your system? when you have that, you'll be able to create a unique qrcode that contains the account Id it's associated with, and you prevent cheating and reuse of the fidelity card all together that way.

When you scan the qrcode, you check the content and if the Id matches the user login account id, then you can use it, else, you simply say, it's not valid.

This way, you don't need any server to handle usage of the qrcode.

https://assetstore.unity.com/search?q=qrcode&k=qrcode


Bye,

 Jean
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on March 31, 2019, 01:16:55 PM
I need in one app, one button, when i press this button, it enable another button in another app. Example both app are open in 2 diferent cellphone. Then when i press the button in the fisrt app, in the other app appear one button, then when i press that button. the button from my app disapear.

How can i do that, is possible?
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 01, 2019, 02:44:09 AM
Hi,

 yes, you can do that using a Multi player network system like pun classic,

https://assetstore.unity.com/packages/tools/network/photon-unity-networking-classic-free-1786

which has full support for PlayMaker on the ecosystem.

https://hutonggames.fogbugz.com/f/page?W928


 Bye,

 Jean
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 01, 2019, 09:07:44 AM
can you do a simple example.
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 01, 2019, 09:45:42 AM
Hi,

 PUN is something you have to learn properly, even if I made you an example, I don't think you would be able to extrapolate on how to implement it properly in your game.

 so before I do a sample showing you that, are you ok with the underlying necessity that you'll need to invest time to learn pun 2 and multi player design patterns?

If you are ok with this, I'll do a quick sample showing you that.

Bye,

 Jean
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 01, 2019, 09:48:36 AM
Yes please
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 02, 2019, 04:35:47 AM
Hi,

 Here we go, the most simple way to communicate between several apps, using Pun.

(https://i.imgur.com/gitf5ym.gif)
 
Make sure you first

- import pun classic: https://assetstore.unity.com/packages/tools/network/photon-unity-networking-classic-free-1786
- import pun support for playmaker: https://hutonggames.fogbugz.com/f/page?W928
- then you can import the package attached to this post


you'll have two scene in PLayMaker Custom Samples/PhotonUnityNetworking/CrossAppCommunication

publish one at least and run the other in editor, or publish both, app A is enabled by default to ping app B, which when pinged shows its own button to ping app A back.

the assumptions are that both app need to connect to photon and join the same room, then they can communicate with one another, via RPC

this is the most direct way to get this done, like a hello world for multi player games :)
 
Let me know if you have questions.

 Bye,

 Jean
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 02, 2019, 09:49:20 AM
this 2 error show.

Operation failed: OperationResponse 220: ReturnCode: 32767 (Empty application id). Parameters: {} Server: NameServer
UnityEngine.Debug:LogError(Object)

The appId this client sent is unknown on the server (Cloud). Check settings. If using the Cloud, check account.
UnityEngine.Debug:LogError(Object)
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 02, 2019, 10:05:42 AM
Hi,

 Pun works with a cloud server which means it has to know where to connect for your players to be together, you need to create an appid:

https://doc.photonengine.com/en-us/realtime/current/getting-started/obtain-your-app-id

https://hutonggames.fogbugz.com/f/page?W982

Bye,

 Jean

Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 02, 2019, 10:33:30 AM
i did the acount put the Id. Its id aplly to the project, I need to fill something else?
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 02, 2019, 10:57:19 AM
i wont enable the button in app 1
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 02, 2019, 01:43:26 PM
i click in the (Join or Create Room), on play in unity it says this.
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 03, 2019, 02:15:19 AM
Hi,

 what version of Unity and PlayMaker and pun do you run this sample with?

 It works fine here.

Bye,

 Jean

Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 03, 2019, 09:08:37 AM
Unity 2018.1.0f2    Pun the one that is in the Ecosystem, is attach the picture.

I need to create a room name besides the AppId 4d76b8ee-f058-4b61-9d26-5032c8ad9916.

Or just import your CrossAppCommunication.packague
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 03, 2019, 09:15:30 AM
I build app 1 and app 2, in windows standalone player to test, but it wont enable the buttons.
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 03, 2019, 10:55:41 AM
Hi,

if you have this error in editor, then it will also error out in build

can you try on a fresh project or is it already a fresh project?

 Bye,

 Jean
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 03, 2019, 11:13:25 AM
i did a fresh project, but still the same, i wont enable the button, and does not work.  im using playmkaer 1.90
this is ok? attach picture
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 03, 2019, 12:29:44 PM
if i click manualy in the appA state (enable content), it enable the button, then i click the button it says, (Cannot send messages when not connected. Either connect to Photon OR use offline mode!)
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 04, 2019, 03:24:43 AM
Hi,

 of course, you need to be connected to photon and in a room.

 I am a bit short of ideas as to why you get this error this way in playmaker, this is odd.

Can you zip your test project and send it to me?

Bye,

 Jean
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 04, 2019, 09:05:23 AM
heres the link of the project.

-Removed Link-
Title: Re: It is possible to save playmaker state?
Post by: djaydino on April 04, 2019, 09:19:59 AM
Hi.
I have removed the link, because the file includes the playmaker.dll file
which is not allowed to share in public.

I have send the link to jean directly, please remove the file after jean replied to you.
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 04, 2019, 09:23:11 AM
ok
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 05, 2019, 02:16:29 AM
Hi,

 ok, I can repro the issue, I am on it, I can't make sense of it right now, but hopefully I'll get the bottom of this soon enough.

 Bye,

 Jean
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 05, 2019, 04:09:24 AM
Hi,

ok, turns out, it was a combination of several things :)

- can you update PUN from the ecosystem, it will make things easier for you with the new version

- then, can you import the package attached to this post, it's new version of the cross app scene, with a better management of the connection which will be easier to run depending on your photon settings setup ( auto join lobby for example and connection to best server settings was putting things off).


Let me know how it goes.

Bye,

 Jean
Title: Re: It is possible to save playmaker state?
Post by: nabilfx on April 05, 2019, 09:51:48 AM
its works thanks, Jean this 20 CCU REALTIME free Photon, is ok to use just for this comunication buttom project?
Title: Re: It is possible to save playmaker state?
Post by: jeanfabre on April 05, 2019, 10:02:53 AM
Hi,

 sure, this is fine. use it as long as you want, the 20CCU license is for real and you can use anyway you like. if you go above, users will not be able to connect ( you can listen to a playmaker event for this, but I think you'll be fine in your case


 Bye,

 Jean
Title: Re: It is possible to save playmaker state?[SOLVED]
Post by: nabilfx on April 05, 2019, 10:32:29 AM
thank you