|
Post by Ash Blue on Apr 25, 2017 6:55:43 GMT
Using the new official Unity 2D tutorial for custom physics character movement, I'm noticing camera jittering with all settings.The issue is pretty easy to reproduce and I can't figure out why it would happen. In LateUpdate it jitters only if smoothness is applied. Really weird, but very annoying and offsetting to viewers. In FixedUpdate it consistently seems to jitter every second or so and I can't figure out why. With or without smoothness applied. Feels like this is the correct setting, but the jittering every second is maddening. I've included a package below that reproduces the above issue with the new official Unity tutorial code. Any suggestions on how to resolve this would be amazing (going mad at the moment reading through PC2D source code to try and figure out what might be wrong).
|
|
|
Post by Ash Blue on Apr 25, 2017 7:53:18 GMT
Well I figured out why the issue was happening. In the tutorial code where they set `rb2d.position = rb2d.position + move.normalized * distance;` at the end of the Movement method. It appears that setting `rb2d.position` doesn't update the transform position until the next FixedUpdate frame (seems like a bug to me). And on some frames it doesn't seem to update at all. Simply adding `transform.position = rb2d.position;` at the bottom with `FixedUpdate` mode on will fix the issue. Which will force sync the transform.
Code Solution:
void Movement(Vector2 move, bool yMovement) { ... rb2d.position = rb2d.position + move.normalized * distance;
// Force the transform to sync immediately instead letting the Rigidbody2D component sync it transform.position = rb2d.position; }
|
|
|
Post by Luís Pedro Fonseca on Apr 25, 2017 11:20:33 GMT
Thanks for posting the solution here Ash. It definitely looks like a bug on the 2D physics system. Glad it's not related to ProCamera2D Cheers!
|
|
|
Post by Ash Blue on Apr 25, 2017 23:58:42 GMT
Hopefully this helps peeps using the new Unity tutorial (hopefully I used proper search terms). As I'd suspect a chunk of people will probably be using for their starting point before adding Pro Camera 2D.
|
|