Facepunch / sbox-issues

177 stars 12 forks source link

Very erratic behaviour when updating transform of a game object depending on FPS. #4925

Closed Fortune117 closed 2 months ago

Fortune117 commented 9 months ago

Describe the bug

In this video you can see the extremely strange behavior of the door.

https://github.com/Facepunch/sbox-issues/assets/7847372/f8b455bb-a1cb-4424-9020-c8d54fece62c

It seems to spasm when closing for some reason. This does not happen when you set your max FPS to 30.

The code for this component is very simple:

    protected override void OnUpdate()
    {
        if ( !isOpening )
        {
            ToggleOpen();
            return;
        }

        currentAngle = interactAngle.LerpDegreesTo( targetAngle, timeSinceStartedOpening / Duration );
        //currentAngle = interactAngle.LerpDegreesTo( targetAngle, 1f );

        GameObject.Transform.World = startingTransform.RotateAround( Transform.World.PointToWorld( RotationPivot ), Rotation.FromYaw( currentAngle ) );

        if ( timeSinceStartedOpening > Duration )
        {
            isOpening = false;
            Scene.NavMesh.SetDirty();
        }

    }

To Reproduce

  1. Open the test repo I've uploaded.
  2. See the bug.

Expected behavior

Game object transforms smoothly.

Media/Files

bug_repo.zip

Additional context

No response

youarereadingthis commented 9 months ago

Related, I am also having issues where setting the rotation(either local or world) OnStart of a child object's transform produces effectively random results, with the correct rotation resulting about half the time.

I have used debug gizmo arrows to confirm that the normal I used to set the rotation is always correct, it's the rotation on the transform itself.

kurozael commented 2 months ago

I believe this was a bug that was fixed with interpolation updates a while back. If this is still an issue, please re-open.