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 john-essy · Aug 22, 2012 at 05:33 PM · weapon system

Robust Weapons System

Hi there and thanks for looking.

The question I have is, I am currently redesigning my weapon system as we have changed the game a bit. I want to be able to have any number of weapons, Add , Remove them in updates etc.

I did have a weapon system that worked great for the last revision of the game but now we have changed it that system just won't cut it any more. We currently have over 20 weapons that can be switched with our MSW all of our weapons have their own stats, (Bullet Speed, Damage, max ammo, Upgrade Cost etc)

With the new system we need to be able to have the same kind off system. The weapons need to have their own stats. We will be allowing players to upgrade their weapons via our upgrade screen the problem i have encountered is i want to be able to access the weapons via their name, As of now we can access them but it is like this

 currentAmmoType[0].damage = 10;

We need to be able to access it like this or something similar

 EnergyBlaster.damage = 10;

As off now i also have it set up so that there is just one class with an array of them and i access them all from there. This is the part i am sure will not work with our new system and i just can't seem to design it correctly. I have been thinking of using a singleton but i just don't want to go down that road. I would love to be able to have an enum and on that weapon just state it is this weapon (EnergyBlaster) and then manipulate it's stats.

I know i can create a script for each weapon and i would do that but i just cant think on how i would be able to allow the player to switch their weapon and i dont think that this is a very nice way t do things. I am a bit of a neat freak which is why i will not do things like above (currentAmmoType[0].damage = 10) i just cant bring my self to do it like this as i know this is a really stupid way of doing it.

I may be over thinking this which is why i am confusing my self on how to design this.

Any Help would be greatly appreciated.

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 Khada · Aug 22, 2012 at 05:50 PM

You want a Dictionary!

Comment
Add comment · Show 5 · 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 john-essy · Aug 22, 2012 at 10:08 PM 0
Share

Thanks! i will check this out. If anyone else has any ideas please share ;)

Again Thanks $$anonymous$$hada

avatar image Khada · Aug 23, 2012 at 05:13 AM 0
Share

You're welcome. Trust me, it's the best way to access a list of items via string etc. When you figure out that I'm right, be sure to mark the question as answered xD

avatar image Khada · Aug 24, 2012 at 02:56 PM 0
Share

Did that end up working for you? Don't forget to mark the question as answered if it did.

avatar image john-essy · Aug 24, 2012 at 03:48 PM 0
Share

I haven't used it yet tbh but from what i have read i am sure it will do the job i need

Thanks

avatar image Khada · Aug 24, 2012 at 03:50 PM 0
Share

You're welcome

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

8 People are following this question.

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

Related Questions

error CS0117: `Util' does not contain a definition for `SetLayerRecursively 0 Answers

Weapon database/dictionary design 0 Answers

CoD style weapon selection 1 Answer

isLocalPlayer does not exist in the current context 1 Answer

How do I stop my weapon from firing while reloading? 2 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