I have a scene for displaying high scores. There are three sets of scores, one for each of the difficulty levels.
The scores are displayed as items (eg. a chalkboard, a whiteboard and a certificate) on shelves. The camera focuses on one of them and pressing a button moves (animates) the camera to the next one.
At the moment, I’m doing that using Lerp interpolation within an Update() method.
Another option would be to have a coroutine that starts when a button is pressed.
Yet another option would be to set up an Animator to handle the movements.
Is there a “best practice” for choosing which to use? Are there solid reasons to pick one over another and what are the most significant factors?
I ask because I’m wondering whether to add ease-in, ease-out to the motion I’ve got, but with Lerp, it involves more coding and fiddling about that if it was being done with an Animator.
No responses as yet, but I was thinking about this today and one factor that seems reasonable is that if the camera motions are always the same, then setting up an Animator to control the motion would be acceptable.
Clearly, if the positions that the camera moves to might vary, then this isn’t possible.
If anyone has ideas about the technical reasons to choose Update() over a coroutine (or vice versa), I would be very interested to know why. Are there efficiency benefits to one or the other?
I don’t think there is any kind of best practice for someting like this honestly. Its all preference and what achieves the result you are looking for.
I did something like this for a menu once upon a time. I used Cinemachine, so each item on the menu had a different virtual camera focused on a button, with slightly different settings for each. I set up different blend modes for easing the cinemachine brain from one virtual camera to the next. Cinemacine is pretty cool, might be worth checking out.
As for update or coroutine, i don’t think its going to matter at all for your menu. To me coroutines are best used for things that don’t need to update forever. In your case though, for a menu, i don’t think performance will be any issue whether you use update or coroutine.
1 Like
After deciding to expand my knowledge, I’ve decided to go with Cinemachine. My setup is now pretty much as you’ve described, with virtual cameras for the different positions.
The only thing I was concerned about was the impact of this on a mobile platform, but I couldn’t find any information at all about it being a problem, so I’ll just have to make sure I can’t see any performance issues when I’ve got a build working the way I want.
Thanks for your suggestions