I want to use Cinemachine to make my sprites follow a track (it’s for a space shooter). So I tried adding a Dolly Track and then I created my sprites and attached the Cinemachine Dolly Cart script. The problem is that the rotation of the sprite is completely off as soon as I attach the script. When I turn it off, rotation is like it should. When I turn it on, rotation is in a way I can’t even see the sprite…
I tried everything I could think of, even make some changes in the Dolly script, but to no avail.
I’ve uploaded 2 screenshots. The first is how the rotation of the enemy should be. The second one is after activating the Dolly Cart script. You can see that the sprite is rotated along it’s y-axis and I’m unable to change that rotation in the inspector. Once the script is activated, the transform controls are locked on the object.
Can someone help please, I’m going nuts atm…
Could you send a few screenshots of your setup? Screenshots of your components and game object hierarchy.
Or you can send me your project and I’ll have a look.
To make the dollyCart move through the dollyTrack you need to set the speed on the dollyCart. After that the simple script will work.
This way, your rotation won’t be locked to the dollyCart’s rotation.
Okay, just to make clear. I wonder if we are talking about the same thing. I can rotate my sprite also, but once I press play, the rotation changes to an angle that’s wrong… The whole ship should rotate so the nose of the sprite is following the curves in the dolly track.
Ah. In that case, you just want to child the sprite to the dolly cart (see the image). Then set the initial rotation on the sprite so it looks forward on your dolly track.
Note, that in this case, you do not need the script I provided.
Just to be sure we’re talking about the same… I can rotate my sprite also, but after I press play it is locked and being rotated in the wrong way. I want the ship and its “nost”
Doesn’t work either. I’m getting tired of this :/. Could you send me a working project with just a dolly track/cart and sprite (preferably with some curves in it) so I can see if this works and what I’m doing wrong ? Thanks !
Okay, this actually works ! But I don’t understand why…The enemy sprite doesn’t even have a component attached that links it to the dolly track/cart and it’s also not a child of the dolly track/cart. So how on earth is this working ?
[UPDATE] Oops, sorry, now I see that the Enemy’s parent is the DollyCart But still I don’t know completely how this can work, because I tried this setup multiple times if I remember right… And I wasn’t able to rotate the sprite once it was a child of the Dolly Cart. Maybe I made it a child of the Dolly Track. I don’t know anymore, I tried a lot of different approaches. Glad to see it work now. There is however another problem. If I want multiple sprites in a row follow the first one, then they all make a turn if the first one does and so they aren’t following the path anymore…
Okay, I can see that, when I attach a second sprite, it follows the transformation gizmo of the first sprite. So I thought, I make a new Cart for the second enemy and so on. But the position transform stays the position transform of the first cart and I’m unable to edit that.
This is working great ! But I still don’t understand why it didn’t work on my side. I also added extra Dolly Carts and one enemy per cart. The only thing that’s different from my solution is that you gave each dolly cart different position and rotation values. But how do I know what values to choose ?
I did not change the DollyCart’s Transform (position, rotation) directly; the Transform values are calculated based on the Position parameter of the Cinemachine Dolly Cart Script. So I only changed the Cinemachine Dolly Cart’s Position value.
You can see the result real-time in the Scene view.
Ah okay, I see it now. Well, finally have a working setup now. Thanks for the time taken to help me out with this. As far as improving the UX: I don’t know what could be altered to make it more intuitive. I guess it’s okay like it is, just a little difficult to setup for a situation like mine. But once you know how, it’s actually very simple So thanks again ! I now can finally start animating my enemies (although I also have some scripts based on sine and cosine to make some “simpler” movements, maybe I’ll even try my hands at a Lissajous curve).