I’m trying to make the camera follow the player and have jittering problem. I’m using physic, updating player on update method (changing velocity) and updating camera to player node position and lateUpdate . I’m not using delta in update for simplicity. I’ve tried executionOrder on Player to -1 with no success. Any idea ?
Thank you for you answer! Can you please elaborate where the part of pre-calculation is made ? Beside the rotation the example is pretty much the same with a getPosition of the target and a setPosition of the camera node, am I missing something ?
Ok this start to look interesting. When I print them (console.log) they are the same and there’s no jittering (with or without chrome console open). I guess is a problem of loop-event not being in sync, what are your thoughts ?
This is because the time frame is not necessarily fixed. So it is possible to update the position of the character at each update using a fixed distance of movement.
I’ve tried to passively update the camera position in the player update loop but it’s the same thing, it jitters. You talk about a “fixed distance”, that means don’t modify the velocity of the player and move both camera and player at the same time ? The project you showed contains an answer to this issue ? If so I’ll try to get more into its logic
What I mean is that by moving a fixed distance each time I mean moving, say, 20 pixels at each update.
Also, my example is not relevant to this issue, anymore.
A possible simple workaround. Try making the camera as a child of the character node. It should in theory follow the node of the character if you are moving the entire node for the controls.
Otherwise, I’m sure there’s a reason to use setPosition instead of editing the position var. I can’t remember what the reason was but setPosition() might help.
I think setPosition and position.x do the same thing, but just to be sure I’ve used both, and the result is the same. Your workaround works but I would like to have more separation between components, that said if no other solution is proposed I think I’ll go for it. Thank you also @Horchynskyi, I’ll test your script, but at a first sight looks like the old implementation I had. One thing I’ve noticed is that on my 100hz screen I have the issue, but on a 60hz everything is ok.