Using Rigidbody3D as moving platform with Tweens

Godot Version

Godot-4

Question

I want to use a RigidBody3D as a moving platform which the player (CharacterBody3D) can stand on and follow the platform automatically (using the Physics Engine, Jolt in my case). Currently I am using a Tween to move the platform along some points I have inside an array, and that works, but it’s directly modifying the global_position and the player does not move along with the platform when standing on it. This is what my very simple code looks like right now:

		for i in metal.positions.size():
			TW.tween_property(object, "global_position", metal.positions[-1], delta * 2.0)
			TW.parallel().tween_property(object, "global_rotation", metal.rotations[-1], delta * 2.0)
			metal.positions.pop_back()
			metal.rotations.pop_back()

The object is the RigidBody3D and the metal.positions is just the array of positions I want the platform to go through. Delta is how long I want the Tween to take from one position to the next.

Replace RigidBody3D with AnimatableBody3D.