|
I'm currently using the following script to create slow motion. However it doesn't smooth out the slow motion by adding the frame information for the frames in between the full speed motion and the new slower motion. By this I mean: full speed has frames A,B,C,D A true slow motion effect at 50% of real speed would create frames in between the above frames: A, a, B, b, C, c, D, d where the lower case frames are exactly halfway between the upper case letters in terms of all object positions and movements. This is not the case for the below code, instead it does this at 50% A, A, B, B, C, C, D, D Where the second A is a repeat of the first A frame, not an effort to figure out the inbetween states of everything. Is there a way to get true slow motion? Here's the code I'm using;
(comments are locked)
|
|
Changing Time.timeScale cause Time.deltaTime to scale according to the time scale. For this to have any effect, you must ensure that all your movement/animation made in Update() properly use Time.deltaTime. Example:
Note that you probably should change Time.fixedDeltaTime as the documentation for Time.timeScale suggests in order for your physics and other fixed time behaviors to work correctly. You'd maybe think Unity could derive information somehow between two calls to Update but that is not how it works. It is up to you to scale animation with accordance to Time.deltaTime (which unity does scale for you). I wish that was more straight forward in the documentation. something like:::::::::: "wanna make slow motion? You need to slow down time, and the speed up the rate things are calculated. You slow down time by changing Time.deltaTime to a number lower than 1. You speed up the rate of calculation of physics and other occurrences during slowdown of time by decreasing the number at Time.fixedDeltaTime." Even this doesn't make logical sense, but will do for now, because it works... increased updates of physics calcs etc would have been better expressed as an INCREASE in rate rather than - time
Dec 22 '10 at 03:47 PM
dissidently
I added the following to the above script, get a smooth slowmotion, but lose all physics control of my "characters" and frame rate drops by a factor of 10. Time.fixedDeltaTime = (Time.fixedDeltaTime / 5);
Dec 22 '10 at 03:58 PM
dissidently
oddly enough, there's no mention in the literature of the default rate for Time.fixedDeltaTime, which means I had to do it this way.
Dec 22 '10 at 03:59 PM
dissidently
Both above answers are right. One is right for physics and one is right for transform created movement... my question is at fault for not expressing which I wanted to remove the stuttering from.
Dec 22 '10 at 04:50 PM
dissidently
Wrong again, both answers are right, full stop. Just took me to figure out the use properly. Can I give both answers a tick? It seems if I choose one it cancels out the other once...
Dec 23 '10 at 10:00 AM
dissidently
(comments are locked)
|
|
Setting Time.timeScale to .5 does result in "true" slow motion; no rendered frames are repeated. The problem you're seeing is that physics runs on its own discrete timer, 50 fps by default, which setting timeScale to .5 effectively halves. One thing you can do is to double the physics framerate to compensate. However, this chews up twice the CPU time when you're not using slow motion. Probably a better solution is to turn on interpolation for rigidbodies, in which case they're interpolated smoothly between each physics frame. would
Dec 22 '10 at 09:46 AM
ina
Not directly, but that's a good question, since that reminds me of the interpolation setting for rigidbodies, which I managed to completely forget about.
Dec 22 '10 at 10:03 AM
Eric5h5
Hey Eric, think you've hit on something here, just about everything in the scene is under the influence of physics forces. Is there a way for me to change the physics discrete timer to ONLY increase during the slowmotion activity?
Dec 22 '10 at 10:40 AM
dissidently
I've just poked around in the physics settings and cant find where to set the physics framerate...
Dec 22 '10 at 10:49 AM
dissidently
Eric, you're a LEGEND. thankyou. Interpolation did the trick perfectly, however halved my overall frame rate :(
Dec 22 '10 at 04:10 PM
dissidently
(comments are locked)
|
