Godot Version
4.2.2.Stable.Official
Question
I currently have an AnimatableBody3D node with a CSGBox3D and CollisionShape3D attached to it, the main goal is to rotate the AnimatableBody3D node so the shapes below work as pendulums for the player to jump across. The rotation logic works, however, it is modifying the position of the entire thing over time, slowly raising it into the air. I have no idea why as there is no position values being modified and when I use Axis Lock they no longer swing, only rotate in place. I have tested with objects that are not offset from the root node and no position issues occur, so it has something to do with offsetting them in this way. Any help is appreciated, and code snips are attached below!
Variables Used
@export var rotation_direction: Vector3 # 0 or 1 values only
@export var loopRotAmplitude: float = 0.1
@export var loopRotSpeed: float = 1
@onready var pivot: AnimatableBody3D = self
Main Logic
func _physics_process(delta: float) -> void:
var rot: float = get_sine()
var rawRot = rotation_direction * rot
pivot.rotation = pivot.rotation.lerp(rawRot, 1 * delta)
Sine calculation for swing motion
func get_sine():
return (sin(time * loopRotSpeed) * loopRotAmplitude)