1
\$\begingroup\$

I'm following along on a game development course and it's going well, but I've come into an issue that I can't quite find the proper words for to google, so I decided that I would ask here. The game is a simple rail shooter, and at the moment we are using the built in timeline animator for unity to animate the course that the camera and ship will follow. In the link to the video below, I explain what the problem is since I find it hard to exactly describe in just words and screenshots. https://drive.google.com/file/d/13C1AK5RLOk3eoPMwMK3SW9Jx6gII7n4_/view?usp=sharing
I'm still getting used to Unity and it's features, so hopefully it's just a simple mistake. If anything else is needed, just let me know and I'll update the question.
And apologies for the extremely low quality of the video, I had to use OBS after NVIDIA crashed, and then it had to get compressed through the editing software and then once more through google docs.Hopefully it doesn't impact what I was trying to explain, but like I said earlier if any screenshots are needed to be able to look at parts that were blurry or anything else then just let me know.

Text summary of the video - Like I stated above, the game is a rail shooter, meaning that the camera and ship will move to pre-determined spots for scripted enemies to show up and shoot at you. On keyframe 1, our ship is facing forward about to take off. On keyframe 2, about a second later, the ship rises up. And on keyframe 3, the ship flies forward and makes a turn, and then makes another turn on keyframe 4. Here's where the problem starts. On the 3rd keyframe, where the ship makes its first turn, instead of rotating the camera from its 2 to 3 position, Unity changes the rotation of the camera from the start. (Ex - If the camera starts facing North but has to make a turn to the west, Unity makes it face West from the start instead of turning from North to West like it should) The odd thing is that this only happens once, because going from 3 to 4 rotates the camera properly. This is the ship's rotation on keyframe 1 This is the ship's rotation on keyframe 1 ^
And this is the same keyframe but after keyframe 3 was animated. So now instead of turning the camera from the original position to the new position in 3, it changed the entire rotation of the camera + ship rig and it now only glides to the new position

\$\endgroup\$
4
  • \$\begingroup\$ Hi! We really need the description of the problem in the text. That way others who have the same problem later will be able to use this Q&A as a reference. \$\endgroup\$
    – Almo
    Commented Jul 4, 2022 at 17:42
  • 1
    \$\begingroup\$ No problem! I added a text summary of the video as best I could describe it. \$\endgroup\$
    – Fnalix
    Commented Jul 4, 2022 at 20:18
  • \$\begingroup\$ I'm completely guessing here, but it could be due to the interpolation mode (looks like it aligns it with the direction of travel). I think the mode is indicated by the squiggle next to the little red circle left of the timeline - see if you can change it; if not, you could maybe try adding an extra keyframe right next to the first one with the same orientation. \$\endgroup\$ Commented Jul 4, 2022 at 23:21
  • \$\begingroup\$ Thank you! That ended up being it. It seems that when a key frame that makes a change for the first time shows up, it makes the change up until that key frame. Since I had not changed the rotation and thus didn't have a rotation key frame before key frame 3, it created one and applied the change for everything before it. \$\endgroup\$
    – Fnalix
    Commented Jul 5, 2022 at 22:50

1 Answer 1

1
\$\begingroup\$

I'm completely guessing here, but it could be due to the interpolation mode (looks like it aligns it with the direction of travel). I think the mode is indicated by the squiggle next to the little red circle left of the timeline - see if you can change it; if not, you could maybe try adding an extra key frame right next to the first one with the same orientation.
– Filip Milovanović

In summary, create a rotation key frame of the original rotation that you want in the "show curves" view on the timeline, so that way any new changes made to the rotation of the object do not update the original orientation. (Ex - If you want your object to start at (0,0,0), make a rotation key frame of the object in that orientation so that any changes only effect the key frame it's supposed to.)

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .