#Camera to body rotation jitter

1 messages · Page 1 of 1 (latest)

proud sparrow
#
    private void HandleIdleBodyRot()
    {
        BodyYaw = RB.rotation.eulerAngles.y;
        CamYaw = CamHolder.eulerAngles.y;

        YawDrift = Mathf.DeltaAngle(BodyYaw, CamYaw);
        float ABSDrift = Mathf.Abs(YawDrift);

        if (!IsBodyTurning && ABSDrift > TurnThreshold)
        {
            IsBodyTurning = true;
            Debug.DrawRay(Player.position, CamHolder.forward, Color.red, 10, false);
        }

        if (IsBodyTurning)
        {
            // track camera while turning (kills the hard-stop jitter)
            TargetBodyYaw = CamYaw;

            TurnSpeed = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, ABSDrift / PanicAngle);
            float newYaw = Mathf.MoveTowardsAngle(BodyYaw, TargetBodyYaw, TurnSpeed * Time.fixedDeltaTime);
            Debug.DrawRay(Player.position, Quaternion.Euler(0f, newYaw, 0f) * Vector3.forward, Color.blue, 10, false);

            RB.MoveRotation(Quaternion.Euler(0f, newYaw, 0f));

            // stop only when drift is actually small
            if (ABSDrift < StopThreshold) IsBodyTurning = false;
        }
    }

How do i fix this jitter

earnest aspen
proud sparrow
earnest aspen
#

!code

atomic mossBOT
proud sparrow
#

ah alr 1 sec

earnest aspen
#

Your mouse look lerping is probably not helping. Not sure if that's the primary issue though

#

Do you have Rigidbody interpolation enabled?

proud sparrow
#

yep

#

its not a kinematic rig btw

#

but turning on iskinematic and using move rotation fixed the jitter

earnest aspen
#

How does the object move generally

proud sparrow
#

however iskinematic stops my whole movement etc from working and i prefer dynamic rb

proud sparrow
earnest aspen
#

Have you tried angular velocity instead of move rotation? I'm not sure if move rotation respects interpolation for non kinematic bodies

proud sparrow
#

i was testing angular

#

move rot doesnt work cause it only interpolates for kinematic rigs

earnest aspen
#

Exactly my point