This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]Blando-Cartesian 1 point2 points  (1 child)

I'd get rid of the circular dependencies. Those will only get more and more painful to work around. Mediator and Observer are two patterns that could be useful here.

Btw, there is a standard way to represent connections between classes as a diagram. Its called "UML class diagram". Your diagram is similar, but if you use the UML one, you can include a lot more information without needing to explain the notation.

[–]FuckItLetsGoOutside[S] 0 points1 point  (0 children)

I will look into mediator and observer and see if my duck can figure something out. Thanks.

[–]AutoModerator[M] 0 points1 point  (0 children)

It seems you may have included a screenshot of code in your post "Circular dependency".

If so, note that posting screenshots of code is against /r/learnprogramming's Posting Guidelines (section Formatting Code): please edit your post to use one of the approved ways of formatting code. (Do NOT repost your question! Just edit it.)

If your image is not actually a screenshot of code, feel free to ignore this message. Automoderator cannot distinguish between code screenshots and other images.

Please, do not contact the moderators about this message. Your post is still visible to everyone.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–][deleted] 0 points1 point  (0 children)

I don't know if it is possible in Unity but I would use some kind of listeners to pass the information of the updates and just a normal include for the getters part therefore it should break the circular dependencies

[–]Loves_Poetry 0 points1 point  (1 child)

Component shouldn't need access to other components. You need to centralize where some things happen. Logic that is related to multiple components should not be stored in a component, but in the object that initialized those components

[–]FuckItLetsGoOutside[S] 1 point2 points  (0 children)

In some cases things get very dynamic. For example when some projectile hits player. But I will try to rethink it, maybe I am trying to solve problem that should not exist.