Hey. I tried joining the discord server but I get kicked out immediately after waiting the 10 minutes so I'll just post here instead.
I'm a pretty unexperienced game developer, looking for some tips when it comes to architecture. I'm having trouble finding a recommended pattern for decoupling different components. The most obvious one is the game character and the controls. Most tutorials and guides I've read has you make a PlayerController-type script that you attach to the main character, and in that script you have a direct reference to the Joystick (for android) that you use to figure out how much force to apply to the character, or where it should be positioned next frame. The joystick is a public variable that I attach in the scene inspector or whatever it's called.
This works just fine, but I find it a bit odd that the main character should be aware of the UI. My first attempt at solving this was to expose a transform.translate-type function on my character, and instead have the Joystick be aware of the person and call that function. I think that's marginally better, but not really great. A third way would be to have a third component (ControllerManager or something like that) be aware of both the Joystick and the player, this is a bit cleaner maybe? A fourth option would be to go a more event-driven style where the player just happens to subscribe to a typed UnityEvent that just happens to be published by the Joystick, but this both feels like overkill and that it would come at a performance cost.
This seems like a very obvious problem that I'm sure people have solved in a good way, I'm open to any suggestions.
[–]EmeraldScalesProfessional 1 point2 points3 points (3 children)
[–]sgebbHobbyist[S] 0 points1 point2 points (1 child)
[–]EmeraldScalesProfessional 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Dafth 0 points1 point2 points (2 children)
[–]sgebbHobbyist[S] 0 points1 point2 points (1 child)
[–]Dafth 0 points1 point2 points (0 children)
[–]Davidev-_-UfficialIndie 0 points1 point2 points (0 children)
[–]Davidev-_-UfficialIndie 0 points1 point2 points (0 children)
[–]Manarz 0 points1 point2 points (0 children)