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 Solu9 · Mar 30, 2019 at 10:36 PM · scriptableobjectscriptable objectimplementationimplement

Need help understanding scriptable objects.

I understand the concept of scriptable objects but I'm having a hard time understanding the implementation. I have a small example case. In this example I want to create a buff system with just two simple buffs. One that heals the user over time, and one that damages the user over time. Both stored on some Power Up gameobject which activates when the player touches it.
My initial thought is to have a list on the player that stores the buffs/debuffs so they can be removed and checked at any time.
I think the biggest problem is implementing different methods for different buffs. As I see it I just need a BuffBase scriptable object which contains an abstract method for activation and maybe a GameObject for the user who runs into the Power Up.

But if I need different methods for a lot of different types of buffs/debuffs and the only thing they share is who the user is and an activation method, which gets overwritten, is there a point in using scriptable objects?
As I understand I will still need a new monobehavior script for each of my buffs with their unique activation method.

Comment
Add comment · Show 3
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 xxmariofer · Mar 30, 2019 at 11:10 PM 0
Share

I dont really understanf your question, is about using scriptableobjects or using parent/childs? If you think you are not going to save any time by using a base class there is no point in using them. Scriptablr objects cant be monobehaviour i think there is something you missunderstood.

avatar image Solu9 xxmariofer · Mar 30, 2019 at 11:32 PM 0
Share

The main question is about scriptable objects as a base. Since I want to store the buffs in a list on the player I need them to be the same type (at least that's what I understand). So if all my buffs derive from the same base and share an activation method from that base. Then I can run through the list on the player and check if eg. the player is periodically gaining health from a buff, or remove a specific buff from the player.

I understand how to create the buff base, but when I want to add what each buff actually do once applied, I hit the wall. Since I want several buffs which behaves differently, for example some are doing stuff periodically in the update, some increases a stat some decreases stats etc, the only way I can think of is having a new monobehavior for each buff. Which kinda seem to remove the concept of having a scriptable object to begin with. Unless multiple types of monobehaviors the way I describe it is completely normal.

avatar image xxmariofer Solu9 · Mar 31, 2019 at 08:26 PM 0
Share

Whats the porpuse of using the scrptable objects? You can add different functionality to each ability why is that a problem? You cant drive fron monobehavior and scriptabke objects

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Hukha · Mar 31, 2019 at 12:48 AM

Hi,

First of all, sorry for my poor English.

You understand SO(ScriptableObjects) bad. SO only store "data". They aren't GameObjects.

I dont recommend it for "Buffs" so i give you an example with other Stuff like "Items".

Imagine you need have 2 types of items(Bows and Swords).

You need a BaseClass SO named "Item" with an enum variable (Or whatever) to identificate the type of this item, and childs of this class named "Bow" and "Sword" with the needed variables for this classes. (Like Damage for the Sword and ArrowStock for the Bows, for example)


Now, you need to create a Item in your project from the child classes and this child have the "Item" class variables and the variables of the child.

[CreateAssetMenu(fileName = "Sword", menuName = "Item/Sword")]


This two Tutorials are good enough to understand SO:

Nice Writed-Tutorial

Video of Brackeys

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 xxmariofer · Mar 31, 2019 at 08:32 PM 0
Share

Why? No, scriptable objexts arent for storing data, thats just a functionality. They are classes, use because they receive events and are easy to serialize. Buffs is a good use case of scriptable objects

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

106 People are following this question.

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

Related Questions

Unique function for each instance of a scriptable object 2 Answers

Unity : Singleton ScriptableObjects resets after play 1 Answer

Need some advice for my inventory system 0 Answers

How to Instantiate objects that are Scriptable Objects 0 Answers

Serializing ScriptableObject into scene without writing to asset 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