How do I get position of a RigidBody that has mode 3 (Kinematic) set to it?

DetonatressDetonatress Posts: 50Member
in 3D

Seems I can't get_pos of this, nor of the Area. I want to make the captured body move toward the center of Area.
I thought converting it to mode 3 would turn it into KinematicBody, but it's not being recognized as such, it's still RigidBody.

func _on_Area_body_entered(body):
    $Area.connect("body_entered", self, "_on_body_entered")

    if captured_crystal == null:
        captured_crystal = body
        body.custom_integrator = true
        body.mode = 3
        var direction = (body.get_pos() - $Area.get_pos()).normalized()
        body.set_pos(body.get_pos() + direction * 5)


  • DetonatressDetonatress Posts: 50Member
    edited June 12

    I tried with updated "position()" instead of get_pos() too, and now it keeps telling me there is no position in base Area, but I have an area node called Area in the scene already.

    I tried with translation:

            var direction = (body.get_translation() - $Area.get_translation()).normalized()
            body.set_translation(body.get_translation() + direction * 2)

    Though I'm not sure how to instead make it smoothly head toward the center of the area (aka coordinate 0 of area) and stop there. I know I have to check if body.translation != keep doing the movement, but I do not know how to code the movement this way.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file