• Godot Help3D
  • rotating child around parent moves child to parent?

I'm trying to have a meshinstance orbit a SpringArm3d (its parent), by rotating the SpringArm3D using this code:

var mouse_senitivity = 0.03
 if event is InputEventMouseMotion:
      $SpringArm3d.rotate_y(-event.relative.x * mouse_sensitivity)

While this does rotate the SpringArm, it also moves the child (meshinstance) right on top of the parent and rotates it there. I don't understand why this happens, I thought child-parent-offsets (including spring length) were maintained when transforming the parent.
Am I using the wrong method?

[apologies for crossposting]

    quickben [apologies for crossposting]

    Cross posting is fine, but link to the other topic too and vice versa, so people can potentially follow the whole discussion.

    And if you get the solution in one place, post it in the other place too. 🙂

    I've never used a spring arm in Godot, but two things come to mind:

    • You said SpringArm3D. That's a Godot 4 node (it's SpringArm in Godot 3). Parts of Godot 4 are a little broken while in beta so spring arms might just not be working correctly.
    • The docs say a spring arm casts a ray along its z axis and moves all child nodes to where the ray intersect hits. So if there's a collider that covers the spring arm, the ray would hit as it is cast, moving the children to the spring arm position. You'll want to use add_excluded_object or the collision mask to make the spring arm ignore whjatever collider is getting in the way.

      Kojack

      Thanks for replying! When I re-checked the SpringArm3d node and its attached script, I found something else: It turns out not the SpringArm3d was the problem, but the fact that I used

      	if event is InputEventMouseMotion:
      		rotate_y(-event.relative.x * mouse_sensitivity)

      in two scripts in the same scene: One for orbiting the camera with a look_at constraint aimed at the player, the other for the SpringArm3d.
      I have merged these scripts and updated the node paths, and now everything (kind of) behaves as it should.

      I still don't understand why having the same Input event polled in two scripts at the same time generated a problem (if it did at all, at this point I'm just confused to be honest).