It moves smoothly, but as soon as I stop moving the mouse, the camera returns into its original position. Could someone help me, please? Thank you so much.
I could be wrong, but I don’t think you’re supposed to subtract the result you get back from lerp at all. Try to simply SET the value instead of subtracting it.
Then your lerp should target -mouseInput.x * mouse_sensitivity, but I think this isn’t what you want either.
Lerp takes the first and second argument and returns a value between the two, based on a percentage supplied by the third argument.
lerp(0, 100, 0.25) == 25
lerp(50, 100, 0.5) == 75
This is often miss-used to smooth movements by supplying the current position (your case rotation) for the first and a target for the second. The third argument only has to be a number lower than 1 and greater than 0 to produce a smooth, but frame-dependant result, multiplying by delta actually makes this frame-dependency significantly worse.
If you want to continue working with lerp you need to define a target rotation much like you applied the initial rotation, then use that as the second argument.
var target_rotation: float = 0.0 # in class body
# in input/process function
target_rotation -= mouseInput.x * mouse_sensitivity
HEAD.rotation_degrees.y = lerp(HEAD.rotation_degrees.y, target_rotation, 0.1)
gives me “Assignment is not allowed inside an expression.” error. Unfortunately, I’m rewriting a player script/plugin, which involves much more I’m able to handle :-/