|
Heya, I was trying to fix this problem on my own for some time, but everything I tried failed so maybe someone can help me with solving that problem. The thing is I have a Character Controller player who is changing its position and rotation in FixedUpdate() function. I have a moving platform ( cube, uniform scale ) and it has one Animation Clip attached which was made in Unity Animation Editor, and the only thing it does is moving the platform. When player stands on this animated moving platform, he is parented to it, so they can move together. Then at last I have Camera which also is calculated and translated + rotated at FixedUpdate() function to remove jitter effects. And everything works great except when player is parented to this moving platform, when big jitter effect is shown. Simpler Camera Script: In my main script camera rotation is also smoothed with Quaternion.Lerp. Problem Effect: http://www.youtube.com/watch?v=1-8Zm3PG4y4 At the beginning the video is normal speed, then it slows to show you it in slow motion ( plus my Frame Rate of capturing dropped then ). Thank in you advande for any kind of help :)
(comments are locked)
|
|
You don't have to calculate the position of or rotate the camera. You just have to child it, as the same way you did with the CharacterController. Make sure, you have made that through the code. Dunno why there was problem with my calculations, BUT your idea delete the jitter effects for now, so big Thumbs Up for you :)
Apr 30 '12 at 12:12 PM
Cinkokoko
The same thing was happening to me! When I parent the camera Gameobject through editor I get the jittering, but when I set the parent through code the jitter goes away, very strange thing indeed! I wonder if there is any difference between these two methods of parenting. Tip: you need to parent only once in Start function and not in the Update function. Thank you venkspower for your answer!
Apr 24 at 09:09 PM
Leocesar
(comments are locked)
|
|
Do not move the camera inside a FixedUpdate. There is no need for that. The pruprose of a camera is to shoot the scene, not playing physics. Therefore, it is a good idea to fix the camera position juste before the scene is rendered. Fortunately Unity provides juste the right event for that OnPreRender (edit: not the best solution, see below): If this doesn't work (I did not try it myself), you can still update the camera position in a latter phase using LateUpdate: edit: LateUpdate is the method to use. OnPreRender does not change position/rotation but can be used to set/unset effects such as fog. There's a problem with it. The reason I changed Camera from Update/LateUpdate to Fixed Update is because when using Update it jitter in many cases, for example when free falling ( even if I use smoothed camera movement )
Apr 30 '12 at 11:58 AM
Cinkokoko
(comments are locked)
|
