Which static/rigid/kinematic body do I need for something that moves very infrequently?

TomnnnTomnnn Posts: 4Member

Hey. I'm working on a scene where the player is in open water and an island emerges from the depths. I would like the island to raise and interact naturally with anything in the water, but then it's going to stick where it is at that point like a static body. Do I want a rigidbody so I can explicit switch it to static mode when it's not moving? If so, I'm struggling with how I go about moving this thing. I assume kinematic mode is what I want for it to be part of physics and push things as it moves with infinite force, but I haven't been able to work that out yet.

Another option I can imagine is making the island a kinematic body so I can move it up with built in move methods. What I have tried and I know is certainly the wrong answer is leaving it as a static/kinematic body and translating its transform origin. Since it's a very large object and it moves very slowly, it keeps objects out of its mesh in a way that isn't too jarring, but I'd love to know how to do this properly.

Thanks!


Tags :

Comments

  • TomnnnTomnnn Posts: 4Member

    Sorry to bump my own post, I don't see a way to edit?

    I think I found my answer, would still appreciate anyone to confirm. I see the documentation for kinematic body mentions it is a good choice for doors / moving bridges. If it is suitable for those, I assume it won't be super expensive and is probably what I'm looking for.

    One question I do have after reading the docs - what is "manually moving" referring to? Is that the api for move_and_collide (and similar) or are the docs actually stating I can directly affect the transform origin (either via tween, animation, or just adding a vector3 to it) and it won't break the physics system? If that's the case, this is a lot simpler than I thought. I just wouldn't have expect that with my experience from other engines.

  • TwistedTwiglegTwistedTwigleg Posts: 2,863Admin

    @Tomnnn said:
    Sorry to bump my own post, I don't see a way to edit?

    No worries! You can edit your opening post anytime through the little gear icon in the top right of the title. If you select it, a drop down should appear that will let you edit the post.

    I think I found my answer, would still appreciate anyone to confirm. I see the documentation for kinematic body mentions it is a good choice for doors / moving bridges. If it is suitable for those, I assume it won't be super expensive and is probably what I'm looking for.

    Probably. A KinematicBody is essentially a tailored RigidBody under the hood, but has several helper functions that make it easier to control. It shouldn't be too much more expensive than a normal RigidBody node, performance-wise.

    One question I do have after reading the docs - what is "manually moving" referring to? Is that the api for move_and_collide (and similar) or are the docs actually stating I can directly affect the transform origin (either via tween, animation, or just adding a vector3 to it) and it won't break the physics system? If that's the case, this is a lot simpler than I thought. I just wouldn't have expect that with my experience from other engines.

    I think when the documentation is referring to "manually moving" nodes, it refers to directly changing their position, rotation, and scale, rather than letting the physics engine handle it. Direct manipulation can lead to issue with physics, so its often desirable to avoid or use the _integrate_forces (I think that's what its called. The RigidBody documentation should mention it) function, as then you can manipulate the node directly without the risk of causing strangeness with the physics engine.
    You can manipulate the node directly in _physics_process, it just may cause some issues in corner cases with the physics engine. I haven't noticed too many issues in my own projects, but your millage may vary.

  • TomnnnTomnnn Posts: 4Member

    Oh wow, didn't see that next to the title, thanks.

    it refers to directly changing their position, rotation, and scale, rather than letting the physics engine handle it. Direct manipulation can lead to issue with physics, so its often desirable to avoid or use the _integrate_forces (I think that's what its called. The RigidBody documentation should mention it) function, as then you can manipulate the node directly without the risk of causing strangeness with the physics engine.

    I see, that's interesting. Usually (in other engines) all physics are out the window if you manually touch positions and things.

    In the short term I'm going to solve this problem by letting the island be a static body and pushing players away from them while they come up from the floor.

Leave a Comment

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