Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by Persona · Feb 11, 2011 at 04:08 AM · gamemenubooleanselectionfighting

how do I set up a character selection menu?

I'm trying to set up a character selection menu for my game, so it can have a VS mode where the player and enemy choice will spawn once the match starts. I know I need to use booleans to do it, but my mind is a bit foggy to the rest.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fireDude67 · Feb 11, 2011 at 04:25 AM 0
Share

What exactly are you trying to achieve? A $$anonymous$$ain $$anonymous$$enu screen, a screen that could select multiple characters the player could control?

avatar image Persona · Feb 12, 2011 at 12:14 AM 0
Share

Pick from multiple characters.

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by burnumd · Feb 18, 2011 at 04:27 PM

You'll want to set up a class that contains information about both the prefab to spawn and any GUIContent associated with the character. The simplest example would be:

//JS
var selectionScreenProfile : GUIContent;
var characterToSpawn : GameObject;

Store a bunch of these in some collection (like an Array).

In your GUI, you'll need to keep track of which player has selected which player, which you can do by keeping an int for each player. So your GUI script may start out something like...

var characterProfiles : CharacterProfile[] //Presuming the script above is named CharacterProfile.js var numberOfPlayers : int = 1;

private var playerSelections : int[];

function Awake () { playerSelections = new int[numberOfPlayers]; }

I don't know how your character selection screen input is supposed to work, but you simply change the number associated with whichever player selected a character, ie, for player 1:

playerSelections[0] = 5

Assuming player 1 selected the fifth character in characterProfiles. In the GUI, you'd draw a box around (or in some other way distinguish) the profile when it's drawn. When you're ready to move on to the actual game stage, you'll need a record of whichever characters the player has selected. So let's add this to the top of the script:

public static var selectedPlayers : CharacterProfile[];

And change Awake to say

function Awake () {
    playerSelections = new int[numberOfPlayers];
    selectedPlayers = new CharacterProfile[numberOfPlayers];
}

And just before you load the fight scene, record those selections:

for (var i : int = 0; i < numberOfPlayers; i++)
{
    selectedPlayers[i] = characterProfiles[playerSelections[i]];
}

When the fightScene loads, have some script get the players and instantiate them (presuming your character selection scene GUI script is CharacterSelection.js:

function Start ()
{
    for (var i : int = 0; i < CharacterSelection.selectedPlayers.length ; i++)
    {
        GameObject.Instantiate (CharacterSelection.selectedPlayers[i], spawnPosition, spawnRotation);
        //Do any other setup associated with player creation.
    }
}
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Persona · Feb 20, 2011 at 04:06 PM 0
Share

I'm assu$$anonymous$$g that for (var i : int = 0; i < numberOfPlayers; i++) { selectedPlayers[i] = characterProfiles[playerSelections[i]]; }

Goes in the update function of character selection?

avatar image burnumd · Feb 21, 2011 at 02:29 PM 0
Share

Nope. The way I've set it up selectedPlayers is static, meaning it (and whatever it contains) will live between scenes. I was presu$$anonymous$$g that your character selection screen would be a different Unity scene than your actual fight stage. So it's basically there as a placeholder to keep a reference to whatever characters your players have selected. That's why I say you should only use that when all the players have selected their characters and you're about to move on to the next scene.

avatar image Darkdragon0011 · May 04, 2015 at 08:51 PM 0
Share

wow thats cool

avatar image
0

Answer by gabriele-picco · Mar 27, 2019 at 09:59 AM

The solution I adopted was to attach objects to the transparent buttons in a scrool rect, so as to manage 3d objects with the convenient of scrool rect interface.


Here you can find the official documentation for use scrool rect: http://docs.unity3d.com/Manual/script-ScrollRect.html


Maybe my assets can serve you ;)

https://assetstore.unity.com/packages/templates/systems/character-selector-pro-113136

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Player movement isn't working 1 Answer

Pause Android game- menu pop-up? 1 Answer

Having trouble with puase menu using standard playercontroller 0 Answers

Cannot set boolean variable from another script 1 Answer

boolean flicker 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges