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
0
Question by DanMarionette · Jan 30, 2011 at 06:23 PM · prefabobjectcomponentdesignmanagement

How to manage a player with upgradable components?

Hello,

I'm creating a space game where the players ship has many components that can upgraded as they progress. I keep getting myself in knots as I try to figure out how best to manage this. The player starts of with a basic version of everything e.g.

Basic Engine, Basic Hull, Basic Fuel Tank, etc....

Some of these components would rely on each other for example, the Engine needs to know if the fuel tank is empty. The fuel tank needs to know how much fuel the engine is burning so to reduce it's fuel amount.

What I started doing was to create a prefab for each component which holds the model and script. Each component script would inherit from a base script for each component type.

My idea was to then add and remove each prefab as children from a main Player prefab that would be the parent for all components and remain throughout the game.

I wasn't sure if to have a Component Manager on the Player prefab or maybe a Player Manager in the scene to control the lot. I then start to get stuck when I think about in the future and adding more component prefabs. Where do I reference these from? I'm going to need something that knows what components the player has bought, not just what they have installed.

Obviously the options don't stop there and I'm beginning to get buried in what I was hoping to keep as simple as possible.

Maybe this is a question of game management as a whole, not just a player. I think with Unity it can be very easy to get carried away with how to do graphics, sounds, moving your character around the screen but I realise that for me the most difficult part of game development is how to design the structure of the game. How your GameObjects load, intereact with each other, how they are saved, loaded and so on.

I would be interested on anyone's thoughts on this? Maybe a work flow you follow with Unity or a design pattern?

Thanks for your time, Dan

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

Answer by Thom Denick · Jan 30, 2011 at 06:58 PM

I don't know if this is the best way to handle it, but I'll tell you how I did it on the game I'm working on.

I have almost the exact same setup. A main character that has 4 components that can be upgraded. My workflow is as follows:

alt text

I hope that's clear enough. Basically you have "Masters" that are gameobjects sitting with scripts that take some of the work out of your character and smaller classes. In my project I have a MusicMaster, a DataMaster, a UpgradeMaster, a GameMaster and more.. most of them do the brunt of the work of actually running the game.

Again this is just one design pattern I've worked on my own from watching lots of Tron. There are different and better ways of handling this as well. For me, it makes the most sense and and keeps me organized which is very important.

Obviously there's more to this than just updating the floats. For example, whenever my size float is updated, I also update my character's scale. In your case you'll want to update your ship's engine model or graphic based on the current Size. If there are say 4 sizes, then just use an int instead, and use a switch: http://msdn.microsoft.com/en-us/library/06tc147t(v=vs.71).aspx to setup the correct model or graphic.

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

No one has followed this question yet.

Related Questions

Is it possible to use Prefabs in the Particle emitter instead of meshes or billboards 1 Answer

How to assign Transform to prefab ? 2 Answers

Procedural generation of prefab objects 1 Answer

Instantiate prefab wihtout dragging prefab into gameObject script 9 Answers

Prefab>>Component>>Revert to Prefab, mass assign? 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