How to make a pushable button with rigidbodies in Unity

Sdílet
Vložit
  • čas přidán 1. 01. 2021
  • Wishlist Project Impulse on Steam: store.steampowered.com/app/19...
    Join The Discord: / discord
    You will learn how to create a completely physics based button out of rigidbodies for your unity 3D game. This will work well for VR games and physics based 3d games.
    Code and Sound: github.com/daniel-ziorli/Phys...
    How to make a physics based button in Unity
    How to make a physics based button in Unity VR
    VR buttons
    How to make a pushable button with rigidbodies in Unity
  • Jak na to + styl

Komentáře • 30

  • @DonionTech
    @DonionTech  Před 3 lety +2

    If you have any questions feel free to comment and subscribe for more!

  • @thebuttonking
    @thebuttonking Před 2 lety +5

    Me and a friend used this for our uni assignments last module, very useful, thank you!

  • @TheKillermonkey29
    @TheKillermonkey29 Před 3 lety +2

    I LOVE THIS GUY. helped me with making my new vr game called dog dude, can't wait for its release

  • @BurAndBY
    @BurAndBY Před 3 lety +2

    POG. You are the best, I was trying to recreate Portal on Unity and nearly made a wrong idea of how to make the button. That was what i wanted

  • @vr_connoisseur
    @vr_connoisseur Před 2 lety

    Great tutorial, worked perfectly!

  • @ramongonzalezfernandez8904

    This is perfect! I made one with spring colliders, but you couldn't press it when it was upside down since the buttons were parented to a static point

  • @fifo4352
    @fifo4352 Před měsícem

    Thanks It's very helpful

  • @_Garm_
    @_Garm_ Před 3 lety

    great tutorial, thank you :D

    • @DonionTech
      @DonionTech  Před 3 lety

      Not my best work lmao but glad it could help!

  • @mrcrensh3299
    @mrcrensh3299 Před rokem +1

    the tutorial didn't really explain how to use the functions at the end. just how to turn on and off a light. like what function would you want to have selected to play an animation

    • @DonionTech
      @DonionTech  Před rokem

      That's the beauty of unity events it can trigger any function. You can create a script with a play animation function and just drag the script in to onPressed. Learn more about unity events to get a better understanding.

  • @hdew12354
    @hdew12354 Před 3 lety

    Hey, quick question, so i've followed the tutorial, i've placed a button in my scene, but when i press play, the putton sorta jitters between the upper and lower limits, spamming itself, so, what might be causing this/how might i fix it? thanks!
    EDIT: i had the parenting order wrong in the heirarchy! (for future reference, make sure the lowerLimit is a child of the UpperLimit

  • @jessemercer5912
    @jessemercer5912 Před 2 lety +3

    This is great! The most clear and easy to follow tutorial ive seen. Hands down. So I'm clearly missing something. I push the button with any object in scene XR Grab Interactable script, a rigidbody, and a collider, or set the item on top of the button, and it works. I cant physically push the button though with my contollers. One arm is a ray interactor, the other arm is a direct interactor controller with a hand prefab with rigidbody and a collider attached to it. What dumb thing am I missing?

    • @DonionTech
      @DonionTech  Před 2 lety

      The most common problem is the mass of the objects. I would decrease the buttons mass and increase the hand mass this should allow you to push the button down.

  • @NarTheNecromancer
    @NarTheNecromancer Před 2 lety

    So when I tried this, any objects with the rigidbody component bounce off of the button.
    Edit: I even tried turning the force down but no matter how low I set it, things still bounce off the button.

  • @sillyman30
    @sillyman30 Před rokem

    when i use the button, i have to push it on its side to make it able to use again, it doesn't go back up unless i push it. is there any fix for this?

  • @berserkervalk2095
    @berserkervalk2095 Před 10 měsíci

    hi i went through tutorial and the sound works when the physics cube touches it but the light never turns on, went through it twice but cant find out why the light never works.

  • @partydaclown6706
    @partydaclown6706 Před rokem +1

    Thank you! Do i have your permission to use this in my game?

  • @memphisperez7290
    @memphisperez7290 Před 2 lety +1

    I attempted the same system but with cylinders, but it doesn't work. The button top just stays inside of the base do you know why this would happen?

    • @DonionTech
      @DonionTech  Před 2 lety

      No idea looks like your colliders are messed up maybe

  • @SW-vy4he
    @SW-vy4he Před rokem

    it's very funny

  • @SirGnomes
    @SirGnomes Před 2 lety +1

    i just typed it all out and realized it was for 3D games 😂

    • @ramongonzalezfernandez8904
      @ramongonzalezfernandez8904 Před 2 lety

      You can probably really easily take out the Z-axis from the code and it should "just work™"

  • @thenecromancer4113
    @thenecromancer4113 Před 2 lety +1

    I'm on a 2D game, but I tried this out, and every time i try to play, the button just vanishes and the "Is Pressed" bool immediately turns on. Is there a way to fix this?

    • @DonionTech
      @DonionTech  Před 2 lety

      I would constrain it to a single axis the x or z'd and use 2d rigid bodies instead I'm not too sure why it's breaking

    • @thenecromancer4113
      @thenecromancer4113 Před 2 lety

      @@DonionTech I’ll try that out. If it doesn’t work, it’s not the end of the world, I just would enjoy this mechanic in my game :)

  • @simpledeck5133
    @simpledeck5133 Před 2 lety

    how do I do it so it makes a sound when clicked

    • @pietrogenovese3076
      @pietrogenovese3076 Před 2 lety

      He shows that in the video, you create a source component and after that you put an audio choose by you.