Character selecting player issue Unity

select player

This article is aim to describe How to want selecting  Character until is run on play scene for better. let’s discussing on this.

character selector1

above figure is this Asset: https://www.assetstore.unity3d.com/en/#!/content/40672

Q:  
Hello  DIller Team,.
.ok. Clear, Last One. . I’am Confusing about Your Code, how to implement to [ Play Game State]. Your Code There Are no Pointing Instantiate Object Character to Call  Play Game State,  I only Founding  Camera Used for the Character display. Can You Explain Me about this Issue..?
Sincerely,
A:
If you are looking to instantiate the selected object chosen by the player, you would need to create a script in your game scene that spawns the selected character. This could done such as:
public GameObject[] m_CharacterObjects;
(We use this one for our games)
OR
public Character[] m_Characters;
The Character[] can be a custom script created by you that has the information for the character, like speed, health, the model, etc.
I would suggest saving the selected character by name, and enabling the object in your game scene with the saved name. An easy way to do this is:
//Create a new string for the selected character
private string selectedCharacterName;
//Call this when the character is chosen
public void OnCharacterSelect() {
    selectedCharacterName = CharacterIndex[currentIndex].name.toString();
 
    //Set a saved int va
    PlayerPrefs.SetString(selectedCharacterName, “SelectedCharacter”);
    PlayerPrefs.Save();
}
More info can be found in the Unity docs here (http://docs.unity3d.com/ScriptReference/PlayerPrefs.SetString.html).
You will also have to load the string value into memory to get the correct object.
Hope this helps.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s