The Mysterious (But Insanely Useful) Hinge Joint Node - Godot Tutorial

Поделиться
HTML-код
  • Опубликовано: 2 янв 2025

Комментарии • 88

  • @KlausWulfenbach
    @KlausWulfenbach 4 года назад +57

    This would be perfect for doors in my 3D game. Static body for the door frame, rigid body for the door, and a hinge joint that handles opening and closing.

    • @garbaj
      @garbaj  4 года назад +11

      That's a clever idea!

    • @Icessien
      @Icessien 4 года назад +5

      It much better than using animations for door opening and closing

    • @jvstAsYouAre
      @jvstAsYouAre 4 года назад +3

      I actually did this but I keep having an issue with rigid bodied in general were at a random point shortly after I have started my game it gets harder and harder to push for example the door around until it just becomes impossible. It's almost like the rigid body just keeps accelerating downwards until it ends up having so much inertia that my puny pill character has no chance of moving it. Any o' yall ever experienced anything like that?

    • @ArcangelZero7
      @ArcangelZero7 4 года назад +1

      Niice! And maybe, if you want it to be more "door like", it can essentially be disabled unless a character / object hits it at a certain speed, in which case it will "enable" the crazy free-swinging :D.

    • @mizuki6048
      @mizuki6048 4 года назад

      lmao

  • @MrNybbles
    @MrNybbles 4 года назад +28

    @1:55 "You'll also see these other options for Bias, Softness, and Relaxation..."
    From the Godot Docs we get some of (but not all) the answers.
    Bias:
    "The speed with which the rotation across the axis perpendicular to the hinge gets corrected.
    "
    Softness:
    "There is currently no description for this property. Please help us by contributing one!
    "
    Relaxation:
    "The lower this value, the more the rotation gets slowed down.
    "
    Well, we got 2 out of 3 at least.
    ---
    Also, the KinematicBody doesn't move because we the developers are expected to apply our own forces to the KinematicBody using either the *move_and_slide()* or *move_and_slide_with_snap()* functions.
    If I set the *infinite_mass* parameter of either *move_and_slide()* to false then I can push a KinematicBody that isn't moving (i.e. directly apply force through game physics), but if I use the hinge joint then I can't indirectly use it to apply force. Odd, but that's the way things seem to work.
    Usually though for a KinematicBody force is applied via the first parameter of either *move_and_slide()* function.

    • @garbaj
      @garbaj  4 года назад +4

      Thanks for the info

  • @5minutemovies977
    @5minutemovies977 4 года назад +30

    Now I can add a fur dice to my car.

    • @garbaj
      @garbaj  4 года назад +14

      This is it. All other uses for this node are banned

    • @ArcangelZero7
      @ArcangelZero7 4 года назад

      Or...(Don't hate me)...truck nuts. :|

  • @multis3484
    @multis3484 4 года назад +22

    Duuude, this will be so useful in my game!! Thanks garbaj!

    • @garbaj
      @garbaj  4 года назад +3

      You're welcome!

  • @NOPerative
    @NOPerative 4 года назад +9

    Now, Garbaj can make a garbage can with a foot peddle activated lid. It's cosmic balance.

    • @garbaj
      @garbaj  4 года назад +4

      perfectly balanced

    • @NOPerative
      @NOPerative 4 года назад

      @@garbaj don't have to be Spiffing to appreciate balance; totes agree!

  • @ishkapoor7931
    @ishkapoor7931 4 года назад +9

    yohooo… you're the best!!! keep more coming... we're following and building great games

    • @garbaj
      @garbaj  4 года назад

      Thanks for your support!

  • @landenisacson7697
    @landenisacson7697 4 года назад +2

    Thank you for sharing this! This has given me a ton of ideas for a possible grappling hook that I could implement.

    • @garbaj
      @garbaj  4 года назад

      Glad to hear it!

  • @sosasees
    @sosasees 3 года назад

    Thanks very much.
    In my previous 2D prototype, I made swinging platforms using 2 hand-made animations (one of them is a mirrored version of the other) that play depending on where the player touches the platform.
    For the style of game that this prototype was (A 2D autorunner with a fixed player speed), this is surprisingly realistic, but required hard work and a little bit of frustration to pull off.
    Now i can do this much easier and much more versatile AND much more convincingly with PHYSICS!, and this makes me go "yes"

  • @Mysda_
    @Mysda_ 2 года назад +2

    If only we had this thing in 2D. I don't understand why there is no way to make a motor in 2D, it's crazy.

  • @Wodsobe
    @Wodsobe 4 года назад +8

    this could be used for swinging in games like spooderman

    • @garbaj
      @garbaj  4 года назад +4

      Yep, that was my first thought when I learned about this node

  • @teacup755
    @teacup755 4 года назад +2

    note kinematic (or rigid bodies in kinematic mode) are essentially static, that is they collide but are not subject to forces, the only difference is the physics engine expects kinematic bodies to move under software control

    • @garbaj
      @garbaj  4 года назад +1

      Ahh, thanks!

    • @teacup755
      @teacup755 4 года назад

      @@garbaj you are very welcome. i am fooling around with bullet physics currently. have some fun with a kinematic (that you control) attached to the joint of your choice to a regular rigid body. the 6dof with spring forces (tuned stiffness and damp if you know basic spring physics) make for an interesting way to nudge rigid bodies around

  • @handsome_lad
    @handsome_lad 4 года назад +10

    Thank you, but can you do a tutorial on a swing grapple hook; like spider-man's kinda.

    • @garbaj
      @garbaj  4 года назад +6

      This video gives you 50% of what you need to know ;)

    • @unknow3238
      @unknow3238 4 года назад +4

      @@garbaj now, just have to figure out how to make a character mouvement as good as the kinematic one, but with rigidbody ! :P

    • @victorpkstrength
      @victorpkstrength 4 года назад

      @@unknow3238 Just for reference, you can set a Rigid body to act as a KinematicBody or a static body. very flexible! docs.godotengine.org/en/stable/classes/class_rigidbody.html

  • @pascalcasier959
    @pascalcasier959 4 года назад +1

    thank you once again for this thing, I had no idea it existed !!

    • @garbaj
      @garbaj  4 года назад +1

      No problem!

  • @MjkL1337
    @MjkL1337 Год назад

    pretty much just like ballsockets and rigid ropes in gmod. awesome!

  • @stevenunderwood9935
    @stevenunderwood9935 2 года назад

    Thank you! This _video_ was insanely useful!!

  • @ArcangelZero7
    @ArcangelZero7 4 года назад +3

    "Can't use it with a kinematic body because they don't interact at all."
    Dang, there goes me trying to use it to cheese a mouse-controlled swiveling 3rd person camera without trying to figure out trigonometry in script. X_X lol
    EDIT: This would be absolutely perfect for a clock-work platformer level!

  • @Red_Eagle
    @Red_Eagle 3 года назад +1

    is motor in radients or in degrees? does it use delta or not? im confused.

  • @Eddieficil
    @Eddieficil 4 года назад +1

    Awesome content!!

    • @garbaj
      @garbaj  4 года назад

      Appreciate it!

  • @Red_Eagle
    @Red_Eagle 3 года назад +1

    now i can make a grapple gun TYYYYYY!

  • @raysandrarexxia941
    @raysandrarexxia941 3 года назад

    Great for orbiting too!

  • @x5queal
    @x5queal 4 года назад

    Thank you, great videos!

  • @boerbol9422
    @boerbol9422 2 года назад

    this is SO useful. Didn;t know about this..

  • @donavenhollow5709
    @donavenhollow5709 3 года назад +1

    Combined with the animation player, this could make for fun traps like swinging axes.

  • @JamesAwokeKnowing
    @JamesAwokeKnowing 2 года назад

    The 'other numbers' are for if the 'static' body is moving very fast, how rigidly does the hinge follow. You'd be surprised that it's not instant and it's like a spring. this is because one is moved 'outside' of physics, and the physics has to 'catch up' and it doesn't do it 'instantly' because that's not physically possible, so it has to move from one place to another, and it gets momentum, etc.

  • @Millu30
    @Millu30 15 дней назад

    If I have a door, how can I make it that character body dont push it away?

  • @ricardoalcantara5846
    @ricardoalcantara5846 4 года назад

    Very informative, first time I see that.

    • @garbaj
      @garbaj  4 года назад

      Glad you found the video informative

  • @youkuya
    @youkuya 4 года назад

    Could you do the other joints? I tried to join a small box to the rigidbody with a spring. I thought it might bounce and swing around as the rigidbody moved. However, the two boxes acted like one box. Knowing how the spring part 6DOF joint works would be very useful for me. Thank you.

  • @blackwhite5721
    @blackwhite5721 3 года назад

    here you learn from the master

  • @sosasees
    @sosasees 3 года назад

    I'm not sure if I'll ever use this idea,
    but I just came up with attaching a rope to a wooden mouse cursor.

  • @nosdregamon
    @nosdregamon 4 года назад +1

    What is the static body in this set-up good for? Just to stop the other body? seems like I'm missing out something. I'll go experiment a bit.

    • @garbaj
      @garbaj  4 года назад +2

      The static body is just an anchor point for the hinge. It doesn't move

    • @nosdregamon
      @nosdregamon 4 года назад

      @@garbaj I know, but the rigid body moves/rotates like it's anchored to the (invisible) hinge rather than the static body, making me wonder if I could simply replace the static body with an empty 3d-Spatial . Or another rigid body and see if they both rotate around the hinge, or ... well I got to wait till I get home from work :)

    • @garbaj
      @garbaj  4 года назад +2

      Yes, you can have both ends be connected to rigidbodies

  • @sziluchannel
    @sziluchannel 4 года назад +1

    Hi!
    Good video! Coul you make an other demonstration about the other types of joints?
    Is there a way to join 2 objects with some joint node, and if i apply too much force, they get separated?
    Edit: Can i do it with simple pin joint?

    • @garbaj
      @garbaj  4 года назад +1

      I don't know off the top of my head how to implement something like you're talking about, but I think it can definitely be done.

  • @Gabriel-rg7cy
    @Gabriel-rg7cy 4 года назад +3

    Unfortunately, godot dont have a 2D Hinge Joint

    • @sosasees
      @sosasees 3 года назад +2

      I found PinJoint2D.
      In 2D, the Hinge and Pin Joints would be exactly the same
      since both could Only rotate around 1 possible axis (Z).

    • @Gabriel-rg7cy
      @Gabriel-rg7cy 3 года назад +3

      @@sosasees Yep. But there are a lot of differences between these. Example, with the HingeJoint you can put a limit in how much can the joint rotate in an angle, Pin Joint no, this is a very useful function.

  • @colly9888
    @colly9888 4 года назад

    This is fantastic!!!

  • @ZEN467
    @ZEN467 2 года назад

    plz make a tutorial on fixedJoint for godot

  • @leo28804
    @leo28804 4 года назад +1

    first idea i had was making a clock

    • @leo28804
      @leo28804 4 года назад +1

      then a door

  • @spirit_x64
    @spirit_x64 2 года назад

    I accidentally discovered that Godot has joints when i was searching "grid" to add a gridmap

  • @ryscale4014
    @ryscale4014 2 года назад

    Can you attach something to the Node A and Node B of a joint, my GDscript instead of assigning them manually?

    • @Ironpants57
      @Ironpants57 Год назад

      Just like referencing any object in godot. If it's a node in your scene you can get it and it's properties.
      Ex:
      1. "onready" the node inside your script
      2. use the "onready" variable you made to change it's properties. "hinge3d.node_a = ???"
      Hover over words inside the ui in Godot. It will tell you which *property to use; *[Property: node_a].

  • @xegrand7548
    @xegrand7548 4 года назад +1

    Can we use the same knowledge to simulate doors ?

  • @jlewwis1995
    @jlewwis1995 4 года назад

    So the pin joint is more like a rope? Whereas the hinge joint is like having something stuck into the object rotating it around

    • @garbaj
      @garbaj  4 года назад +1

      hinge joints rotate on a single axis, kind of like a door hinge. Pin joints can rotate freely in all directions

  • @mobilegamer4201
    @mobilegamer4201 4 года назад

    Garbaj can you make a video about healthbar

  • @gooficat
    @gooficat Год назад

    Two words: Grapple. Hook.

  • @rattenliebhaber7840
    @rattenliebhaber7840 4 года назад +1

    Nice but I didn't finde a Hinge Joint Node 2D

    • @garbaj
      @garbaj  4 года назад +1

      Yes, Hinge Joint is 3d only

    • @sosasees
      @sosasees 3 года назад +1

      I found PinJoint2D.
      In 2D, the Hinge and Pin Joints would be exactly the same
      since both could Only rotate around 1 possible axis (Z).

  • @maeggid192
    @maeggid192 2 года назад

    How can Disconnect and Connect a coneTwistJoint via Script? Truck_Town in godot-Demo has a coneTwistJoint

  • @SteelyWing
    @SteelyWing 3 года назад

    Godot joint glitch when over limit, try so many way but no one works perfect.

  • @Parataiga
    @Parataiga 4 года назад

    Do u have patreon or something ? I'd love to give u atleast something for your awesome Content!

    • @garbaj
      @garbaj  4 года назад +1

      Not yet, but I haven’t ruled it out

  • @sigitsatriap6505
    @sigitsatriap6505 4 года назад

    Interesting ...

  • @cmds.learning7426
    @cmds.learning7426 4 года назад

    cool

  • @guyincognito5663
    @guyincognito5663 4 года назад +1

    Doesn’t exist for 2D.

    • @garbaj
      @garbaj  4 года назад +1

      That is correct

    • @sosasees
      @sosasees 3 года назад +2

      I found PinJoint2D.
      In 2D, the Hinge and Pin Joints would be exactly the same
      since both could Only rotate around 1 possible axis (Z).