- Home /
Jittery Movement
Maybe I'm just blanking on how transform.translate is supposed to work but I'm getting really jittery movement when i try to do even simple forward movement. Its fine in the editor, it only shows up on android. im hitting a framerate of ~25 which is lower than id like but isn't low enough to cause the amount of jitter i'm seeing, and even if it was I would expect to see it on other objects. I'm also only seeing it on the player which is being moved like this. The player has a kinematic rigidbody, and a trigger collider, I'm not relying on physics for anything so translate shouldnt be fighting with that I wouldn't think.
private void Update()
{
travelVector = horizontalSpeed * Time.deltaTime * CachedTransform.forward;
CachedTransform.Translate(travelVector);
}
Answer by hrgchris · Apr 04, 2017 at 03:34 PM
Hi there
This is a guess without knowing more, but seeing as it works in editor (presumably high framerate) but not on Android, and it is related to physics-type-stuff, FixedUpdate vs Update instantly springs to mind.
If your rigid body has a velocity but you are also moving it with the Update function then they are going to conflict a little (this might even be the case with 0 velocity - would need to test it). The conflict would be less visible at a high frame rate, as the Update will be running as fast (if not faster) than the FixedUpdate. However at a lower frame rate when you're doing fewer Updates per second, the fighting between physics and none-physics might be more visible.
Apologies for the vague answer - would need to do some experimenting to know more, but I would suggest starting by placing that code in a FixedUpdate function and see what happens. If your object has a rigid body you should probably be using RigidBody.MovePosition anyway though (again within FixedUpdate).
-Chris
Answer by TSI25 · Apr 04, 2017 at 04:50 PM
Ultimately I had to rework movement quite a bit to allow for the camera to be parented to the player which seems to solve the jitters. I think the main problem was both a low framerate, and the camera follow script in the end.
Your answer
Follow this Question
Related Questions
Jittery movement of sprite on device 1 Answer
Jittery Movement (2D) 4 Answers
Movement jitter every few seconds 1 Answer
Character movement jerks left and right? 0 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers