The camera goes back to it's initial position when using Lerp

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CosmoXD

Hello, I’m trying to create a camera for a little editor (A camera that you can move using the mouse wheel), It moves using the position of the mouse when is pressed the middle button of the mouse, but when I try to move it it goes back to it’s initial position.

This is the code:

public override void _UnhandledInput(InputEvent @event)
{
    if (@event is InputEventMouseMotion mouseMotion)
    {
            if (Input.IsActionPressed("middle"))
            {
                double delta = GetProcessDeltaTime();
                GlobalPosition = -GlobalPosition.Lerp(GetGlobalMousePosition(), 2 * (float)delta);
            }
        }
    }

Here is a video of the problem:

:bust_in_silhouette: Reply From: aXu_AP

I think the problem is in the GlobalPosition = -GlobalPosition... You are negating the coordinates every frame. Remove the minus sign, and it should work :slight_smile: