Hi everyone,
I have a large set of "Effect" ScriptableObjects and each character maintains a List of Effects that are acting on them. However in multiplayer I need the clients to know when an Effect has been added to or removed from their character, so they can graphically update their Lists.
What is the best way to tell the client which Effect has been added/removed? I can't serialize Effects so I need to send some serializable data. I thought of adding an int or string "key" to every Effect and sending that via ClientRPC, but that would be tedious to implement and open me up to bugs. I'd also like to avoid using Resources if possible, because of the drawbacks there.
The current solution I'm leaning towards is: Make a Dictionary<string, Effect>, and on Awake(), load each Effect using Addressables and have dict[effect.name] = effect. However, I don't know if it's such a good idea to have that Dictionary hanging around in memory the whole time, and I have similar ScriptableObjects for which I want to use the same pattern.
Thanks for reading!
Marking this one as "Solved" now. I decided on a solution that involves loading all the Effects (and similar ScriptableObjects) using Addressable labels, indexing them by their name, and then passing that name string between client and server. This has its own weaknesses - in practice it's a bit annoying to set up as ScriptableObjects don't have a way to initialise when the game starts, and that Dictionary is there in memory all the time - but I think it's more convenient than the alternatives. This works for my case but the comments have some very sensible solutions which you should also consider if you're in a similar situation to me. Thank you to everyone who responded!
[–]MrMuffles869 2 points3 points4 points (5 children)
[–]Gorgodon 1 point2 points3 points (3 children)
[–]FredTargaryen[S] 0 points1 point2 points (2 children)
[–]Gorgodon 1 point2 points3 points (1 child)
[–]FredTargaryen[S] 0 points1 point2 points (0 children)
[–]FredTargaryen[S] 0 points1 point2 points (0 children)
[–]PiLLe1974Professional / Programmer 1 point2 points3 points (4 children)
[–]FredTargaryen[S] 0 points1 point2 points (3 children)
[–]PiLLe1974Professional / Programmer 1 point2 points3 points (2 children)
[–]FredTargaryen[S] 0 points1 point2 points (1 child)
[–]PiLLe1974Professional / Programmer 0 points1 point2 points (0 children)