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 /
  • Help Room /
avatar image
0
Question by Ganimedes · Sep 24, 2012 at 02:03 PM · characterselectioninstantiated

instantiating player to different scenes

i'm trying to put together a simple Character Creation screen, when create button is clicked a GUI pops up with 3 different characters depending on which you choose it will be instantiated into the scene, with the ability to create more than one character. so you can have 3 animated instantiated objects to pull into the next scene(world) depending on which character you want to play. think of the diablo 2 character selection screen. or MuOnline here is an image of what im trying to achieve.

alt text

Comment
Add comment
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

1 Reply

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

Answer by nikescar · Sep 24, 2012 at 07:18 PM

You could have a public static variable that the character's prefab name is assigned to.

Something like this in your character select screen script:

 public static GameObject selectedCharacter;
 
 public GameObject character1; // drag character prefabs here in the inspector
 public GameObject character2;
 public GameObject character3;
 
 void OnGUI()
 {
      if (GUI.Button(Rect(10,10,50,50),"Character 1")) 
      {
          selectedCharacter = character1;
          // Put instantiate code here for display in the selection screen
      }
      if (GUI.Button(Rect(10,35,50,50),"Character 2"))
      {
          selectedCharacter = character2;
          // Put instantiate code here
      } 
      if (GUI.Button(Rect(10,60,50,50),"Character 3")) 
      {
          selectedCharacter = character3;
          // Put instantiate code here
      }
 }

Then in your level loading script you would access selectedCharacter by using the script/class name first and then selectedCharacter. Kinda like this:

 Instantiate (CharacterSelectScreen.selectedCharacter, Vector3.zero, Quaternion.identity);
Comment
Add comment · Show 7 · 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 Ganimedes · Sep 25, 2012 at 03:09 AM 0
Share

im getting an error; "You can only call GUI functions from inside OnGUI.

avatar image Ganimedes · Sep 25, 2012 at 03:18 AM 0
Share

dont worry changed update to OnGUI

avatar image nikescar · Oct 03, 2012 at 10:57 PM 0
Share

Oops. Fixed that.

avatar image kabxlo · Jan 25, 2016 at 05:23 PM 0
Share

I'm still shaky on the concept, where do I exactly out the instantiate class ? @nikescar

avatar image ShadyProductions kabxlo · Jan 25, 2016 at 05:25 PM 0
Share

You can also use dontdestroyonload method.
http://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html

avatar image yanjing · Jun 08, 2016 at 11:02 AM 0
Share

Where should i put the level loading script?

Show more comments

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

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Character selection 0 Answers

Plane character selector unity problem 0 Answers

How do I save a previously bought characters in my Game? 0 Answers

Array of Texts that change dynamic on selected character 0 Answers

I have my animations created. Now what? 0 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