Comments (7)
Hi sjai013,
The answer is, just DON'T INSTANTIATE PREFAB.
Keep all the GameplayEffectSpec stuff, and replace GameplayEffectScriptableObject : ScriptableObject with GameplayEffectPrefab : MonoBehaviour, and it should work.
The fact is that you can read data from Prefab without instantiating it, and do comparing with no problem. Just like ScriptableObject.
I was thinking why not just making an example for this. So after 20 min of copy-paste, here it is:
https://github.com/yangrc1234/unity-gameplay-ability-system
Check main branch newest commit for changes.
Very few code is edited, most changes are converting scriptable object in the original example to prefabs.
No prefab is instantiated, everyone is happy.
from unity-gameplay-ability-system.
from unity-gameplay-ability-system.
Thank you for you reply!
I know ScriptableObject is good for storing data, and I use them a lot too. But they just lack some abilities comparing to UE4 data-only blueprint. Maybe I'm just not clear enough to get you to the idea, sry for my poor english hah.
But here's a great blogpost I found that exactly tells what I mean with some examples: https://blog.gemserk.com/2020/05/26/using-unity-prefabs-and-gameobjects-only-for-data/
from unity-gameplay-ability-system.
Thank you for the link to the blog post. I can see the value in what the author is saying, but I'm concerned about the overhead prefabs introduce.
As a reference, the current approach is to keep track of the applied GE in a list (the "AbilitySystemCharacter" class). A GameplayEffectSpec is created from the GameplayEffect SO (much like how UE's GAS works) - the GameplayEffectSpec is an instantiation of the GameplayEffect SO, so it can contain mutable data (the GameplayEffect SO is considered immutable). This list is iterated each frame to update the remaining time for durational GE. Similarly, the list can be searched to identify the current remaining time for a specific GE (which matches a tag).
Using a prefab system instead as you suggest, how would you propose identifying an applied GE? Would this involve creating a new prefab for each applied GE? This would be massive bottleneck - imagine a scenario where you're creating 100s of GE every frame. This would not be very performant. Once those prefabs are created, where would you put them in the scene? Nested under the main character? Would you keep track of the GE prefabs (presumably, you would cache the Duration Monobehaviour on those GE) using a list on the character?
from unity-gameplay-ability-system.
Thanks for that. I see your point. This certainly seems to be a more powerful approach - I'm now not able to see why you would ever use SO when you can use prefabs in this manner.
I'll update the repo at some point for this. I really appreciate your feedback, thank you! Feel free to close this issue when you're done.
from unity-gameplay-ability-system.
Good to hear that!
I think the source of this issue is that, Unity doesn't have a equally flexible system comparing to UE4 blueprint.
Prefab can be "inherited"(prefab variant), but we can't change the MonoBehaviour on it to a derived version. (while in UE4 we can inherit an blueprint, changing its logic and data)
And ScriptableObject is even more weaker. Hoping they can bring up a similar "ScriptableObject variant" solution.
But using Prefab system here has an advantage over UE4 GAS, that is we could extend data/logic by adding scripts to Prefab; Add child GameObject to Prefab.
while UE4 is using UObject sub class for GameplayEffect/Ability, which can't have any Component.
Just some random thoughts.
I'll share my thoughts during my development anytime in the future. :D
from unity-gameplay-ability-system.
Just referencing this here for future reference:
https://blog.unity.com/technology/making-cool-stuff-with-scriptableobjects
Unite '16 LA - Richard Fine (at 6mins) talks about using SO instead of non-instantiated prefabs.
from unity-gameplay-ability-system.
Related Issues (8)
- v0.61 branch demo scene not working, due to no input handling HOT 1
- Looking forward to seeing continuation of this project! HOT 5
- Download Demo HOT 4
- Is the repo stop update ? HOT 1
- Ability Tags not working HOT 1
- This framework is too hard to use,had learned this for a day and still can't use it well HOT 1
- Would this support network multiplayer like in UE4? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unity-gameplay-ability-system.