There's a lot of things I can do to improve character sync across the network so that it doesn't look choppy. There's also the option of moving colliders forward when you move, but I'm not sure if that is the ideal thing for a shooter.
What I'm doing is trying to use Lerp with a modded version of the stock
TNet Sync Rigidbody prototyping script. I've omitted the complete script and only listed the changes:
[RFC(1)]
public float positionLerpFactor = 0.01f;
public float rotationLerpFactor = 0.25f;
void OnSync (Vector3 pos, Vector3 rot, Vector3 vel, Vector3 ang) {
mTrans.position = Vector3.Lerp(mLastPos, pos, positionLerpFactor); // Lerp from the old pos to the new pos
mTrans.rotation = Quaternion.Lerp(Quaternion.Euler(mLastRot), Quaternion.Euler(rot), rotationLerpFactor); // Lerp the rotation to the new rotation
mRb.velocity = vel;
mRb.angularVelocity = ang;
UpdateInterval();
}
The result is a nicer, smooth movement of the player, but when it stops movement the player jerks a little bit forward then snaps back a bit into the correct position. I think this must be due to the Lerp "snapping". Rotation is still a little choppy but it does smooth it out to some extent since I'm updating the Rigidbody data 10 times a second over the network.
There's also this code block here, but I'm not sure if I'll touch this as this is the actual sync function:
public void Sync () {
if (TNManager.isInChannel) {
UpdateInterval();
mWasSleeping = false;
mLastPos = mTrans.position;
mLastRot = mTrans.rotation.eulerAngles;
tno.Send(1, Target.OthersSaved, mLastPos, mLastRot, mRb.velocity, mRb.angularVelocity);
}
}
So, anything I'm doing wrong or any suggestions?