Godot Version
godot version 4.7.1
Question
Hello devs, I think I’m having a noob problem
**
AnimatableBody3D collision doesn’t push/interact with RigidBody3D when rotated by mouse**
I have a spoon controlled by the mouse. Its CollisionShape3D visually intersects with an egg (RigidBody3D), but the egg doesn’t react at all.
The player’s CharacterBody3D collision works correctly against the egg.
The spoon is currently attached to the camera and is rotated/moved by code.
How should I set up the spoon so its collision correctly interacts with the RigidBody3D egg?
player script:
extends CharacterBody3D
@export var speed: float = 5.0
@export var gravity: float = 20.0
@export var jump_force: float = 7.0
@export var mouse_sensitivity: float = 0.002
@onready var camera: Camera3D = $Camera3D
var camera_rotation: float = 0.0
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
# چرخش چپ و راست پلیر
rotate_y(-event.relative.x * mouse_sensitivity)
# چرخش بالا و پایین دوربین
camera_rotation -= event.relative.y * mouse_sensitivity
camera_rotation = clamp(
camera_rotation,
deg_to_rad(-85),
deg_to_rad(85)
)
camera.rotation.x = camera_rotation
func _physics_process(delta: float) -> void:
# Gravity
if not is_on_floor():
velocity.y -= gravity * delta
# Jump
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = jump_force
# Movement
var input_dir := Input.get_vector(
"move_left",
"move_right",
"move_forward",
"move_backward"
)
var direction := Vector3(input_dir.x, 0, input_dir.y)
direction = direction.rotated(Vector3.UP, rotation.y)
if direction != Vector3.ZERO:
direction = direction.normalized()
velocity.x = direction.x * speed
velocity.z = direction.z * speed
move_and_slide()
spoon scripts:
extends Node3D
@export var sway_amount: float = 0.02
@export var sway_speed: float = 8.0
@export var max_sway: float = 0.08
var target_sway := Vector3.ZERO
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
target_sway.x = -event.relative.y * sway_amount
target_sway.y = -event.relative.x * sway_amount
target_sway.x = clamp(target_sway.x, -max_sway, max_sway)
target_sway.y = clamp(target_sway.y, -max_sway, max_sway)
func _process(delta: float) -> void:
position = position.lerp(target_sway, sway_speed * delta)
target_sway = target_sway.lerp(Vector3.ZERO, sway_speed * delta)
the node trees:



