Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndrew Molloy
37,259 PointsWhy FixedUpdate for Animation?
Nick Pettit, I think I have to disagree with the reasoning for using FixedUpdate here. By multiplying by Time.deltaTime you're already making it a constant update no matter the frame rate and so the fly RotateAround should be placed in Update rather than FixedUpdate. FixedUpdate really should only be used for physics engine related/reliant updates. The only real difference is on a system where the frame rate is very fast you're not going to take advantage of that because you'll be missing frames to update a render by putting the change in rotation in the constant frame rate of FixedUpdate(), and on a very slow frame rate system you're wasting calculations that won't be rendered.
But it's late in the day so I may be missing something. :) Great intro course otherwise for beginners (I've gone through a few over the years for Unity), very practical.
2 Answers
Nick Pettit
Treehouse TeacherI'm pretty sure you're correct! Originally I had some code there that used a rigidbody and I needed FixedUpdate() and now I can't figure out why I still used FixedUpdate... Whoops. :P
I'll have this corrected soon!
Alan Mattan贸
Courses Plus Student 12,188 PointsIf you make the game physics at 0.03(33fps) of a second of FixedUpdate and then you change to a FixedUpdate of 0.01 (100fps) the animation will run faster. Multiplying by Time.deltaTime give you the ability to prevent certain problems and maintain the speed of the animation if the physics time step is change later in your project.
Andrew Molloy
37,259 PointsUnless you used Time.fixedDeltaTime which would account for that, but then that's only if it's really necessary to have inside FixedUpdate.
Alan Mattan贸
Courses Plus Student 12,188 PointsYes, Time.fixedDeltaTime
Nick Pettit
Treehouse TeacherNick Pettit
Treehouse TeacherJust FYI: Time.deltaTime will read the same if you're in Update() or FixedUpdate()
See here: http://docs.unity3d.com/ScriptReference/Time-fixedDeltaTime.html