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
3
Question by Nolan Encarnacion · Oct 10, 2010 at 04:51 PM · instantiateswitchswitch characters

How is the best way to handle switching characters

So I have a basic ship and essentially, i want the ship to "level up". both ships are different prefabs within the scene, and I don't know the best way to actually handle this.

Should i go ahead and instance them in the start function with an empty game object serving as my initial position?

I would like to hear your thoughts about this?

Thank you!

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
2
Best Answer

Answer by jashan · Oct 10, 2010 at 05:10 PM

There are a couple of approaches you could follow for this and which one is the best depends on your specific needs. In particular, it depends largely on how different your different ships are and how you have the logic put into scripts.

One approach that I think should work pretty "generally":

  1. Create prefabs with only models for the different "ships"
  2. If needed, have a "property script" that keeps your specific settings (e.g. speed, ammunition, characteristics of weapons etc.)
  3. Have a "ControllerPrefab" that is just an (empty) game object with all your scripts that handle the behavior of the ships/characters attached
  4. Have "slots" for all ship/character prefabs on that controller prefab
  5. Have a "default ship" (which you use when you first instantiate your ControllerPrefab)
  6. When the ControllerPrefab is instantiated, immediately instantiate the "default ship"
  7. When you switch (or instantiate the default ship), destroy anything that's below your ControllerPrefab (if there is anything ;-) )
  8. Instantiate your new "ship" and use transform.parent to attach your model prefab to the ControllerPrefab
  9. Make sure to set the references in your ControllerPrefab-scripts that need access to the "specific configurations" to your new prefab

With that kind of approach, you could also set up LOD-systems comparatively easily.

Comment
Add comment · Show 1 · 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 Nolan Encarnacion · Oct 12, 2010 at 06:33 AM 0
Share

... wow never thought about that! I've only been program$$anonymous$$g for a year T.T and this unity stuff is all new to me! Thanks again!

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

No one has followed this question yet.

Related Questions

Developing a Universal Unity Game and tips. 0 Answers

Switch Statements 1 Answer

switching between in game characters 2 Answers

Changing player model with keypress. 3 Answers

Switching Player 1 Answer


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