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 /
This question was closed May 07, 2018 at 08:15 AM by Myth for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Myth · Feb 14, 2011 at 12:36 AM · componentupgradevehicle

Vehicle Upgrade System

Hi all,

Imagine you are playing a game. You buy a fighter and get enough experience to upgrade it. You talk to a "mechanic" and a window comes up with buttons displaying the pictures of the components to be upgraded.

And this is where I got stuck.

How would I go about creating a script that will be attached to the "mechanic" that will allow many vehicles to be upgraded with many upgrades. (the upgrades are physical components like new engines, turrets etc requiring the instantiation and parenting of prefabs).

I can create menus and instantiate things but have no Idea how I should do the rest. Arrays have been suggested to me but are handled differently in unity to what I am used to.

Any and all help is appreciated.

Thanks.

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

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by celadon · Feb 14, 2011 at 07:20 AM

If you are able to program in C#, you can go beyond arrays and use some of the generic collections to simplify things for yourself. I would think you'd probably want to create some kind of hierarchy of classes to store your upgrade data - e.g. you could start with a class like VehicleUpgrade that stores data like upgrade name, the type of vehicles it applies to, the upgrade category, etc. - but I am sure it will get more complicated quickly. For example, you may have different classes you can add into this one that represent different upgrade components and store their data.

If you are using C#, then you can use collections like strongly-typed lists or dictionaries (e.g. List or Dictionary which is much easier to use and more type-safe than just a plain old array.

But really, for a system like this, it seems like how you structure all of the data about a given upgrade is a lot more complicated than how you store the different upgrades themselves...

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 Myth · Feb 14, 2011 at 10:01 AM 0
Share

So js is out for this kind of system?

avatar image Jesse Anders · Feb 14, 2011 at 10:45 AM 0
Share

@$$anonymous$$yth: UnityScript has support for at least some of the generic .NET containers, such as List, as well. (I can't tell you off the top of my head what other containers are or are not supported.) In any case, you should definitely be abe to implement what you describe using UnityScript.

avatar image celadon · Feb 14, 2011 at 07:56 PM 1
Share

I agree, you can certainly do something like this in either JS or C#. I$$anonymous$$O, the issue of what kind of collection to use is a distraction. You have a lot of info to keep track of - e.g. the name of the prefab, the texture to use in the GUI interface, cost, whatever. You need to figure out how to structure it all logically before getting worried about how to store it in the code. The logical structure will deter$$anonymous$$e the specific implementation you need.

avatar image
1

Answer by Jesse Anders · Feb 14, 2011 at 03:54 AM

Arrays have been suggested to me but are handled differently in unity to what I am used to.

This is probably where I'd start. In C# at least, arrays are handled no differently in Unity than anywhere else. I'm not that familiar with array use in UnityScript, but I do know that the idiosyncratic way in which multi-dimensional arrays were handled has been addressed in the latest version of Unity. Aside from that, I'm willing to bet array use in UnityScript is pretty conventional as well.

So, perhaps you could edit your post (or post a comment) and describe in what way array use seems to differ from what you're used to. Arrays (and containers in general) are invaluable tools, so if there's something keeping you from using them, that's the problem you'll want to address first (IMO).

Comment
Add comment · Show 2 · 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 Myth · Feb 14, 2011 at 10:00 AM 0
Share

The arrays I have used in the past used a co-ordinate system to access and were like a filing system that up to 255 boxes and within each of those, up to 255 more and so on up to 255 times.

avatar image Jesse Anders · Feb 14, 2011 at 10:47 AM 0
Share

If you mean a multi-dimensional array, then those are supported and shouldn't be any different from what you've encountered in the past. In any case, there's nothing unusual about how arrays and other containers are handled in Unity, so don't hesitate to make use of them.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

2D Animation does not start 1 Answer

unity 5 upgrading errors 1 Answer

car slides to the right or left when i accelerate... why? 2 Answers

Vehicle sound help? 1 Answer

Raycast Car-Vehicle Physics 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