Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 MisterHasacz · Jul 14, 2016 at 10:43 PM · classesdictionaryskills

Problem with making skill system for my creatures

Hi. I want to make some skill system for my creatures. I see it like that:

  • Write classes for all skills (they inherit from some abstract base class and I want all skills to perform different action, preferably in coroutines if possible)

  • Add all of them to some static general dictionary (all skills have unique string id)

  • Add some default skills to my creatures (let's say i want one of them to have Fireball, Kick, Roar, the other to have Acid, Thunder Bolt, Attract etc.)

  • And finally let players change specific creature's skills (remove, add, maybe upgrade) in some menu.


I wanted to make it like this: http://answers.unity3d.com/answers/873150/view.html


But i have some questions:

  • Should i create separate script for every skill? Or can i just have all classes in one script with base abstract class? Or maybe abstract class in one script and all inherited classes in other script?

  • Do i have to attach skill script with base skill class/inherited skill classes to game object? Because they have to derive from MonoBehaviour if i want to use coroutines (i think)

  • How and when i should skills to general dictionary?


Or maybe there's better way to do it?

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

Answer by joshua-lyness · Jul 15, 2016 at 12:41 AM

Its a tricky thing to tackle, since "fireball" probably massively changes the way the creature interacts. I'm doing something similar in a game i'm making, it's a city builder and there are lots of tools such as the road tool, zoning tool etc. These tools are each scripts on a manager gameobject. The manager object also has a manager script. Each of the tool's scripts has an "active" Boolean, and the manager script turns the Boolean on and off. You can do something similar, by having a manager script on each creature, and scripts for each skill on the creature. The manager script can then turn the skill scripts on and off by changing the stage of an "active" Boolean. Just an idea, but it's a solution that would work. :)

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 MisterHasacz · Jul 15, 2016 at 10:37 AM 0
Share

But let's say i want to have overall 100 skills and one creature can only have 4 in the moment (but players can swap one skill for another). So i have to add 100 scripts to each creature but mark as active only available ones? Can that have negative impact on performance?

EDIT: or maybe implement some type feature and for example to water type creatures add only water type skills. That's certainly better than adding all of them.

avatar image joshua-lyness MisterHasacz · Jul 16, 2016 at 12:35 AM 0
Share

It shouldn't be negative on performance any more than putting it all in one script is, unless you're changing other scripts' variables a lot. The thing with skills is that an entire script might be necessary. Let's say the skill is something like explosive punches, that's going to involve a lot of code, whereas super run wouldn't, that would just change a variable. Either way, if you choose to put it all in one script, having a "selection" class would be appropriate, to control which skills they have. Your best bet might be an array of integers, with the skills each having its own index that the array will hold (so for example if the array had the numbers {1,24,6} in then that might point to skills {jumpHigher, runFaster, timeTravel} or something like that. It's really an open ended question and all I can give you is ideas.

avatar image MisterHasacz joshua-lyness · Jul 16, 2016 at 04:30 PM 0
Share

ok, thank you :D

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Combine duplicates in a collection of class objects 0 Answers

Cannot use custom type as key for dictionary 0 Answers

How to refer to object based on value of a variable 1 Answer

rpg, skills and characters the structure, confused 0 Answers

Referencing the object that a construtor is currently constructing/working on. 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