Hi,
After a little exploration I’ve become very excited by the idea of Component Based Design in conjunction with Unity, but having had almost no experience with it, I’m not sure how best to start.
I therefore have two questions to ask the community, one broad and one specific:
-
The broad question: are there any guidelines or standard programming practices on how best to develop a good component based architecture with unity?
-
The specific question: I have been writing my own behaviour components for a camera system (3rd person chase cam, rails cam, fixed tracking, etc) and am now looking at writing other modules such as ‘shakey camera’ and ‘camera spring’ which I could use at the same time as one of the behaviour scripts - e.g. a chase cam with shakiness, or a rails cam with springs.
However, as both scripts would have code to change the position and lookat values of the camera, how can I control their combined behaviour? I thought that maybe I could control the order in which the script Update() methods are called, but it looks like that would be incredibly unreliable.
Am I doomed to have to simply include ‘shake’ and ‘spring’ code into each of the camera behaviour scripts and use a bool to turn them on and off? that kind of code duplication makes me weep.
I feel sure that this is the exact kind of thing that that Component Based Design is made for but am not sure how to use it properly. Can anyone help?
Thanks a lot.