this post was submitted on 02 Jul 2023
16 points (100.0% liked)
Unity
427 readers
1 users here now
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I feel like I'm on the verge of the same revelation but not quite getting there. What was the tipping point for you?
Given every script that inherits the interface needs to provide its own method still, it feels like there's always an alternative to using interfaces to me but I'm sure I'm not seeing the full picture. It does also feel odd to have a floating c# script that isn't attached to anything for the interface itself. I always wonder how exactly Unity/the game knows of its existence but I guess it's keeping a track of every file in the project folder(s).
The two pieces that really made it extremely useful for the game I'm working on was being able to 1) find/call methods from a script without knowing its name, and 2) find/ collect objects that don't have any similarities in properties/tags/layers/scripts other than inheriting from the interface.
It has freed me from making some arbitrary additional scripts linking these completely different object types and lists to handle and track interactions whiles also enabling each object type to react uniquely to a situation. For the longest time it just felt like interfaces were helpful in organizing and creating consistency, but now it's allowing for these cool chain reactions in my game that I didn't expect.
Not sure if that entirely makes sense with my lack of sleep!
Motivates me to keep going. Thanks!
Good luck!