Hi all,
I think this is more of a design issue rather than any issue with physics or Godot, but I am stumped on how to solve it.
I started the project in Godot 4.4.1, but promptly ported to 4.5 beta 2 due to the physics interpolation rewrite, which so far has been a God send! I am using jolt physics.
My problem is that as the camera follows the player, if it collides with any objects, it will have a noticeable "springing effect" at physics ticks rate seemingly lower than 40. Allow this video to demonstrate the problem.
https://www.youtube.com/watch?v=aMBK6SOjZNQ
My setup is as follows.
The player is a CharacterBody3D node, with a simple character controller script.
The camera is a separate scene and uses the "gimbal" setup, it consists of a Node3D as root, another Node3D which acts as a pivot, a SpringArm3D node, a Marker3D node as a child of the SpringArm3D, and finally a Camera3D node, which lerps to the position of the Marker3D node. See the attached image. The script to control the camera is here, and yes it is super messy, forgive me. https://pastebin.com/1Z11tugN
I think the problem is that because the camera scene follows the player by lerping towards the player, and the camera lerps to the position of the Marker3D node, this is what causes the "springing effect", because the camera is being told to lerp to one position, while the camera's root node is also being told to lerp to the player position.
How can I solve this? I just can't seem to come up with a solution that is fully satisfying. I've tried modifying the code to only follow the player if it's not colliding, but that means if the camera collides with any object, it stops following the player altogether. If anyone has solved this problem in the past and could share some pointers, I'd much appreciate it!
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.