I know this might sound like a stupid idea, and maybe we’re missing out some basic feature to do that in another way; we’re creating an opening cutscene for our demo, and we need to move a character along a path, having a camera following it.
The thing is: Cinemachine doesn’t seem to have a script similar to the dolly track to apply to GameObjects, so what we’re doing is parenting our character to a dolly and using that to move it.
But “why”, you might ask? Because it’s way easier than doing it in the timeline or in the animation panels, and it’s way faster to iterate over. Its not perfect though; for example, it’s very hard to precisely ground the tracks
The question is: is there a better way to do that?
The cutscene we’re talking about can be seen here:
Also, but thet’s a secondary question, any idea why the camera following the oranghe character in the beginning is shaking? we’re using a simple follow offset and a lookAt.
Cinemachine comes with a script called CinemachineDollyCart. Add that to a GameObject to make the GameObject follow a path. You can animate the cart’s path position, or give it a speed.
As for the shaking, it might come about because you’re parenting the character to a vcam, and then using that as a target. There is no way to guarantee the evaluation order of vcams - that’s why you shouldn’t use them as targets.
Switch to dolly cart, and the shaking will likely disappear.
As said, we’re already using the DollyCart+Track to move the character (and the butterfly); my question was mainly about it being the intended usage, as it appears to be from your answer. In that case, allow me to suggest to take in consideration the development of tools to easily “ground” tracks; when you have a non flat terrain it’s extremely hard to make sure the tracks follow the ground level (of course one could write his own grounding script but, you know, I’m assuming we’re not the ones with this need ).
For the shaking, the character is not parented to the vcam. The vcam is unparented, and has a normal follow+aim setup; that’s why I have no idea, it looks like the vcam is sometimes updated at different speed than the target it follows (the orange guy parented to the dollycart as explained before).
I thought you were talking about a DollyTrack vcam.
Juddering is often caused by things being animated on different clocks (fixedDeltaTime vs deltaTime). We will have to investigate further to look for the culprit. What clock is your vcam animating on? What clock is your dolly cart animating on? What about the character? Can you show images of the inspectors of your DollyCart and Brain inspectors? Also the scene hierarchy showing the relevant bits.
For the path tools, we agree they are rather skimpy right now, and we do intend to expand them. We understand that when it comes to path algorithms, there are many use-cases and there is no one-size-fits-all. Happily, Cinemachine will work with any path code that implements ICinemachinePathBase, so you can fairly easily implement your own custom path type and use Cinemachine with it.
You can also look into CinemachineDollyCart.cs and see that the code is very simple. It is intended partly as an example to use if you want to implement your own behaviours that follow paths. One possible enhancement that comes to mind is forcing the path onto a surface. That is, query the path for a point, then zap its Y coord to ground level before using it. Then, you could get the behaviour you’re looking for while not being too finicky about keeping the path itself exactly on the ground. Just an idea.
Putting a GameObect on a path this way is so useful, I feel like this should be more common knowledge. So many applications. Will use this for a lot of different effects in the project I am working on involving predetermined pathing, this solved a tricky issue for me. Thanks!
Any way to have a smooth integration of this method with another way of moving objects? it looks pretty bad how objects snaps to the point 0 of the dolly track as it is.
How can we blend between the transform or rigidbody normal movement of a character, to this dolly cart approach, in a SMOOTH way? because if your character is not 100% aligned with the start of the path spline it will just SNAP to it no matter what… and that looks poorly done if you see it in a serious videogame, so any way we can modify the functioning of the script? or can you consider adding a “smooth transition” check on the script for a future update? i’d say even for cinematic purposes, having a camera snapping to its start position looks weird, so it would be nice to have the chance to choose between a clean cut to the start of the spline, or a smooth transition of the objects to the start of the spline.
What script are you talking about? Is this about characters moving smoothly, or cameras moving smoothly? I still don’t understand what you’re asking. With Cinemachine you can get smooth camera movement if you set it up properly.