Demo Project for 3D Joints (HingeJoint, SliderJoint etc.)

wombatstampedewombatstampede Posts: 173Member

3D Joints can be a bit overwhelming. At the time of this writing some of the Joint Classes also have some issues.

So a bit of demonstration might be helpful therefore I put together a little demo project so you can watch and modify the behaviour of joints in 3D. This project was created using Godot 3.1beta3.

Download: 3D Physics Joints Demo Project

Screenshots:


Comments

  • TwistedTwiglegTwistedTwigleg Posts: 2,616Admin

    This looks really useful @wombatstampede! I'm positive this will be helpful, at least for me, as I never really could quite grasp how the 3D joins work in Godot and have not had time to play around to figure it out. Thanks for making this, I'll have to try it later! :smile:

  • wombatstampedewombatstampede Posts: 173Member

    I've got the impression that 3D Joints are still a bit of an uncharted territory. The docs about joints are minimal and available demos seem to be rare. So I hope that his thread can be helpful for people getting to know 3D Joints in Godot. I'd also be happy if other people share their findings in this thread.

  • gamesimadeforfreyagamesimadeforfreya Posts: 2Member

    @wombatstampede This demo has been very helpful. I'm trying to create a rope swing mechanic. Do you know if there is any way to limit the amount each of the PinJoints can get pulled away from eachother?

    When I attach a kinematic character to the bottom of a "rope", created by chaining RigidBodies and Pinjoints together, the characters gravity just pulls the Bodies and joints appart.

  • leewangleewang Posts: 5Member

    Great resources, thanks!

  • cyberealitycybereality Posts: 927Moderator

    Welcome to the forum @leewang!

    This project also looks pretty interesting.

  • Bitdom8Bitdom8 Posts: 2Member

    Hi https://godotforums.org/profile/wombatstampede. Thanks for great tutorial. How can we separate 2 hinged bodies from each other without freeing them?

  • Bitdom8Bitdom8 Posts: 2Member
    edited May 4
    Have found the solution
    
    export(NodePath) var node1
    export (NodePath) var node2
    
    var player_node
    
    
    func fly_the_kite(player):
        holder = player
        if flied_the_kite:
    #       leave_follow_me()
            print("nomore")
            flied_the_kite = false
    #       PhysicsServer.joint_create_hinge(get_parent().get_node(str(player)).get_rid(), get_parent().get_node(str(player)).transform, get_node_or_null("Box5").get_rid(), get_node_or_null("Box5").transform)
            Global_batch.carried_object_items.erase(self.name)
            return
        else:
            flied_the_kite = true
            print("nomore2")
    #       PhysicsServer.joint_create_hinge(get_parent().get_node(str(player)).get_rid(), get_parent().get_node(str(player)).transform, self.get_rid(), get_parent().get_node(str(player)).transform)
    #       follow()
    
            var gg = HingeJoint.new()
            add_child(gg, true)
            node1 = get_node("../Player").get_path()
            node2 = self.get_path()
            print(get_node("./HingeJoint").get("nodes/node_b"))
            get_node("./HingeJoint").set("nodes/node_a", get_node(node1))
            get_node("./HingeJoint").set("nodes/node_b", get_node(node2))
    #       get_node("./HingeJoint").get("nodes/node_a") = String(node1)
    #       get_node("./HingeJoint").get("nodes/node_b")
    
            Global_batch.carried_object_items[SAVE_KEY] = self
            return
    
  • wombatstampedewombatstampede Posts: 173Member
    edited May 5

    Hi, Bitdom8!
    Good that you found a solution.... albeit I don't see in your code how you actually unlink the joint.

    I'd think setting the nodes/node_a (or node_B) to NodePath("") should unlink a body from the joint. But perhaps it is that what you've done.

Sign In or Register to comment.