#FN 3.1.1 to 3.2.0 csp owner jitter possibly due to predicted object?

22 messages · Page 1 of 1 (latest)

scenic wraith
#

I've been using FN in my project for ~8 months without any jitter issues.
I would love to start updating to 3.1+ to make use of the network improvements done and what'll come in the future.

Since v3.1.1 (cleaned old FN) I have been having a hard time trying to figuring this out.
Character controller prediction, prediction type: Other (not rb).
Usually it's more apparent with Cinemachine Framing Transposer + damping. But I believe it isn't due to cinemachine itself.
Tickrate is 8. CM brain is in Late Update. I'm uploading a demo I made inside CharacterControllerPrediction scene.

PredictedObject interpolation at 1 tick seems to be jittering, at 2 ticks I think eliminates jitter but it's too long (slippery feeling), I feel like I want to have something in the middle. But I think there's a deeper issue that I'm not aware of.

Any help would be greatly appreciated net

spring torrent
scenic wraith
spring torrent
#

That's something in your CSP. Maybe you need to not process input of default?

scenic wraith
scenic wraith
#

I had time to give this another try

  • tried using an old (fn 2.x) predicted object scripts and the jitter was still there, so this issue is probably only related to csp yeah.
  • tried the setup in a new empty project with a clean fn, transform prediction instead of cc, same behavior
  • disabled reconciliation, same behavior
  • observation: jitter when using cinemachine damping in framing transposer with high values of "soft zone". Just tried it with a value of 0.1 and it was almost not jittering, better than a hard lock at least.
spring torrent
#

@spring torrent bumping this for myself because I keep meaning to put this in a guide.

#

I was going to show you what I had but I suspect your findings about soft zone are right. It seems I have mine up as well

scenic wraith
#

@spring torrent I just realized the culprit, it doesn't have to do with the new csp features. It's just because I followed the new csp examples and guides where the client moves at OnTick only. However when I re-used the older approach, which had TimeManager_OnUpdate the client used to Move() with Time.deltaTime (and Move() if replaying) then the predicted object doesn't jitter anymore

spring torrent
#

Ah yeah that happens. I actually made that mistake recently moving some old code.

scenic wraith
spring torrent
#

thats if you wish to use the timemanager for frame updates

#

thats tick independent

junior egretBOT
#

FirstGearGames received thanks.

red basin
scenic wraith
#
public CharacterController CharacterController { get; private set; }
        
        private MoveData _clientMoveData;
        
        private void Awake()
        {
            InstanceFinder.TimeManager.OnTick += TimeManager_OnTick;
            InstanceFinder.TimeManager.OnUpdate += TimeManager_OnUpdate;
            
            CharacterController = GetComponent<CharacterController>();
        }

        private void OnDestroy()
        {
            if (InstanceFinder.TimeManager != null)
            {
                InstanceFinder.TimeManager.OnTick -= TimeManager_OnTick;
                InstanceFinder.TimeManager.OnUpdate -= TimeManager_OnUpdate;
            }
        }

        public override void OnStartClient()
        {
            base.OnStartClient();
            CharacterController.enabled = IsServer || IsOwner;
        }

        private void TimeManager_OnTick()
        {
            if (IsOwner)
            {
                Reconciliation(default, false);
                CheckInput(out var md);
                Move(md, false);
            }

            if (IsServer)
            {
                Move(default, true);
                var rd = new ReconcileData(transform.position);
                
                // Reconcile only every X ticks
                if (TimeManager.Tick % 2 == 0)
                    Reconciliation(rd, true);
            }
        }

        private void TimeManager_OnUpdate()
        {
            if (IsOwner)
                MoveWithData(_clientMoveData, Time.deltaTime);
        }

        private void CheckInput(out MoveData md)
        {
            md = default;

            if (IsFrozen) return;

            var horizontal = X
            var vertical = Y

            if (horizontal == 0f && vertical == 0f)
                return;

            md = new MoveData
            {
                Horizontal = horizontal,
                Vertical = vertical
            };
        }

        [Replicate]
        private void Move(MoveData md, bool asServer, bool replaying = false)
        {
            //Sanity check!
            if (asServer)
                if (IsFrozen)
                {
                    md.Horizontal = 0;
                    md.Vertical = 0;
                }

            if (asServer || replaying)
                MoveWithData(md, (float)TimeManager.TickDelta);
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse //Wrong ReSharper assumption
            else if (!asServer)
                _clientMoveData = md;
        }

        private void MoveWithData(MoveData md, float delta)
        {
            if (IsFrozen && IsClient)
                return;

            if (IsFrozen)
            {
                md.Horizontal = 0;
                md.Vertical = 0;
            }

            var direction = new Vector3(md.Horizontal, 0, md.Vertical).normalized + new Vector3(0,Physics.gravity.y,0);

            //Move char controller
            if (CharacterController.enabled)
                CharacterController.Move(direction * (_currentMoveRate * delta));
        }

        [Reconcile]
        private void Reconciliation(ReconcileData rd, bool asServer)
        {
            //Skip, if client and disabled reconciling
            if (!asServer && !_clientReconcile) return;

            transform.position = rd.GetPosition();
        }
junior egretBOT
#

xaldin received thanks.

scenic wraith
# red basin thank you!

np! this is technically FirstGearGames original csp code from old versions (except for minor changes I made like reconciling every 2 ticks, take care of that)

red basin
#

I am just absorbing as much info about CSP as possible, because I also have issues of my own and doing this stuff right now 😛