HyunWol
September 14, 2022, 3:52am
1
Previously, I used the ScriptableObject.
public class AbilitySO : ScriptableObject
{
[SerializeField] TargetingStrategy targetingStrategy;
[SerializeField] FilterStrategy[] filterStrategies;
[SerializeField] EffectStrategy[] effectStrategies;
public void Use(GameObject user) { }
}
First, I use the Sriptableobject in IComponentdata.
But ScriptableObject managed type.
Therefore, it is not accessible from Jobs.
Second, I use Interface.
However, I cannot use Interface as a T parameter in places such as SystemBase.HasComponent, etc.
Please give me a good opinion.
I suggest you are use search DOTS forum, as we have discussed that in few instances.
Search for skills, and ability keywords:
https://forum.unity.com/search/16069877/?page=2&q=Ability&t=post&o=date&c[node]=147+583+641+422+425
https://forum.unity.com/search/16069910/?q=Skills&t=post&o=date&c[node]=147+583+641+422+425
Two threads you may find for example, are:
If skills amount is fixed
You can basically use component with skills values.
This allow to have fixed job, which executes all relevant skills, accessing component’s skills value.
Or having multiple components, each component hosting own skill.
This allows to have own job per skill.
In case your skill amount changes
You can use dynamic buffer, which uses lets say reference to the skill type, i.e. enum, and the actual value.
But then, you need iterate through skills in a job, and having…
I was unable to find a good way to do composition with ScriptableObjects. It just seemed like no matter what I tried, I couldn’t find a way to make ScriptableObject composition as straightforward as dragging components onto a prefab. I haven’t played with any Visual Scripting tools and to be honest I’m not real crazy about visual scripting solutions. So for now I am going back to using prefabs instead of ScriptableObjects.
If you dig more, you will find more solutions and discussions.
1 Like
Or this one : DOTS skill system repo available
Based on your post, you mays also be interested in learning about BlobAsset, that’s what I use to convert my scriptable ability to entity world (sigleton entity).
Also about interface you may want to have alook at generic systems/jobs, relevent ressources :
Talk about the additionnal requirement for generic job/systems
In case it will help, here’s what we’ve been doing. This is what broke when using Entities 0.14 and Unity 2020.2. This used to compile fine - Burst had no problem detecting these generic job for JIT and AOT:
We started with a problem: Most of our jobs shared 90% of the same logic & component types. But 10% was always unique to each job. We knew it would be crucial to our workflow to figure out a way not to repeat a bunch of the same logic in each of our dozens or hundreds of such jobs.
(Our pa…
Exemple of generic reactive system.
This version works with empty component. (note: with empty component we don’t check for change in value as tehre is none). There was no change to the interface. you can drop in the new abstract system in place of the old one and all should work.
using Unity.Burst;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using Unity.Jobs;
public interface IComponentReactor<COMPONENT>
{
void ComponentAdded(ref COMPONENT newComponent);
void ComponentRemoved(…
2 Likes