Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: nohailokha on August 25, 2018, 11:34:00 AM

Title: character selection menu [SOLVED]
Post by: nohailokha on August 25, 2018, 11:34:00 AM
hi
im getting a trouble in the selection menu . how can i make the selected character
in selection menu scene  stay saved when starting game scene
sorry for my bad english
Thaanks first
Title: Re: character selection menu
Post by: djaydino on August 25, 2018, 12:51:19 PM
Hi.
You could use playerprefs actions for this.
It will even be saved if you restart the game or you can reset it when starting the game.

For example you could use an int (1 : character one, 2 character two, and so on.

When you load the scene load the int and use a 'Int Switch' to set the character.
Title: Re: character selection menu
Post by: nohailokha on August 25, 2018, 10:23:22 PM
thanks for your reply . what sould i add in the key variable and the value ?
Title: Re: character selection menu
Post by: djaydino on August 26, 2018, 12:03:13 AM
Hi.
The 'key' is a reference to that variable so if you call it "CharacterSelected"

Then you need to use that reference to read or change the value.

The value is the int variable for your selected Character.

So after you selected a character (for example character 3) then you can set that value by using 'PlayerPrefs Set Int' key : CharacterSelected Value : 3 (best to use a variable instead of a number)

in the next scene use 'PlayerPrefs Get Int' key : CharacterSelected and use a variable to get the value (which will be 3)

Now you know Character 3 is selected in the other scene :)
Title: Re: character selection menu
Post by: nohailokha on August 26, 2018, 10:31:15 AM
thank you  but i didnt work i think i m missing something in variables . i wish if you can make an exampleproject for me  . Thanks
Title: Re: character selection menu
Post by: djaydino on August 26, 2018, 11:48:57 AM
Hi.
I made you a sample, but i used a single scene.
But you can do the same in 2 scenes (top part Scene 1, bottom part Scene 2) once you understand how it works.

just import the attachment below into a project that has Playmaker installed
Title: Re: character selection menu
Post by: nohailokha on August 27, 2018, 03:44:12 AM
okay thank you so much im gonna try it
Title: Re: character selection menu
Post by: nohailokha on August 27, 2018, 07:25:05 AM
it finaally works thank touu so much Djaydino .
Title: Re: character selection menu
Post by: djaydino on August 28, 2018, 05:21:49 AM
Hi.
Happy to help  ;D
Title: Re: character selection menu [SOLVED]
Post by: bbs950064 on November 03, 2020, 02:30:12 AM
How do I assign the characters to int?
For example, pressing button 1 will select character 1
Because the example above is directly targeting the button as a character
If I need to separate characters and buttons into different objects, how do I correspond to each other?
Title: Re: character selection menu [SOLVED]
Post by: djaydino on November 03, 2020, 01:45:03 PM
Hi.
I am not sure what you mean, can you give a sample.

Do you mean a on screen  button or a controller button?
Title: Re: character selection menu [SOLVED]
Post by: bbs950064 on November 07, 2020, 01:19:26 AM
for example, i have a button that i want to use to choose next car and previous car, but how to click the button to change the car show on the screen
and how to set the car that i choose in my next scene ( or in my gameplay )
like this :
Title: Re: character selection menu [SOLVED]
Post by: djaydino on November 07, 2020, 01:22:23 PM
Hi.
The Ui Button actions can detect pressing a button.

Then You can save (you can use PlayerPrefs actions to get/set (load/save)) what that button pressed in a variable.

on the other scene load what you selected and get the car prefab you need
Title: Re: character selection menu [SOLVED]
Post by: bbs950064 on November 30, 2020, 07:49:02 PM
ok! thank your help! i will try to make this  ;)