I’ve been trying to solve this issue for a while now, have come across several threads, but haven’t been able to figure out where I’ve messed up. I am procedurally generating a mesh terrain from a heightmap with a mesh collider. I’ve taken it into a separate project of it’s own to be sure nothing else was causing the issue.
My player object in this test project is just a capsule with a rigidbody, capsule collider, and a click to move script. Interpolate is turned on.
void FixedUpdate()
{
if (_target != Vector3.zero)
{
Vector3 dir = _target - transform.position;
float dist = dir.magnitude;
if (dist < curMoveSpeed * Time.fixedDeltaTime)
{
rb.MovePosition(_target);
dir = Vector3.zero;
//anim.SetBool("Moving", false);
_target = Vector3.zero;
}
else
{
dir /= dist;
//anim.SetBool("Moving", true);
}
rb.velocity = dir * curMoveSpeed;
}
}
Also a script on the camera just to follow the target position, also using FixedUpdate.
I’ve tried Update, FixedUpdate, LateUpdate, both for the player and camera movement and individually. I’ve tried fixedDeltaTime, smoothDeltaTime, deltaTime, time… I’ve tried PhysicMaterials with No Friction…
After everything I’ve found and tried, my movement still seems ‘jittery’ to me. As if it moves in bursts of speed, rather than a constant smooth motion… So am hoping someone can help figure out what I’m doing wrong, or maybe suggest a different approach. Am just trying to achieve smooth movement across the surface of a mesh terrain that’s generated on startup. I’ve usually used navigation to handle all of my movement, but can’t in this project, so I feel like I’m probably overlooking something simple.
Thanks for any help/suggestions!