A Beginner's Guide to Making VR Buttons

Let's use some joints and physics to interact with the virtual world using...BUTTONS!
Hey, devs! Buttons are one of the primary ways that players interact with the world. In this video, we use a configurable joint and two cylinders to fire "Pressed" and "Released" events that can be used to do any number of actions, from turning off and on lights and doors to activating a rocket launch! Give it a shot, and let me know what you use your buttons for!
📺 Watch Next: • What Do I Need to Beco...
🥽 Enroll in the (now FREE) VR Creator Academy: skool.com/vrcreatoracademy
⌚ Timestamps
0:00 Like!
0:28 Setup & Settings
2:00 Building the button
3:33 Adding physics to the button
6:20 Code
11:54 Testing
13:21 Get the source project on Patreon!
14:14 Comment!
#vr #buttons #untiy

Пікірлер: 179

  • @simonschirber8908
    @simonschirber89082 жыл бұрын

    Great Video Series. It is really crazy how much goes into what seem like simple interactions and remembering this all so there isn't a need to copy.

  • @Riprog
    @Riprog2 жыл бұрын

    Thanks Justin, great tutorial and easy to follow! Hope you get a lot of patreons and can keep uploading awesome content like this.

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Much appreciated!

  • @JustinPBarnett
    @JustinPBarnett3 жыл бұрын

    Download the Project (for FREE): www.vrcreators.io/codedownloads

  • @tiodwiakbar5225

    @tiodwiakbar5225

    3 жыл бұрын

    I really love your tutorial. And gonna subcribe your patreon. But i have one question. Is the final project is apk? Cause my laptop only has 1050ti gpu. Thanks. Sorry for my bad english

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    @@tiodwiakbar5225 thanks! And you can build out the project as an .apk by swapping your build platform over to android

  • @tiodwiakbar5225

    @tiodwiakbar5225

    3 жыл бұрын

    @@JustinPBarnett ok thank you so much. Im gonna subscribe your patreon today

  • @westparezal

    @westparezal

    2 жыл бұрын

    When you create tutorial about hand pose?

  • @DevDunkStudio
    @DevDunkStudio3 жыл бұрын

    Love your guides! They are really helpful

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Thanks!!

  • @asolondev
    @asolondev3 жыл бұрын

    Very useful, thanks for the great video!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    You're welcome!

  • @Xzarations
    @Xzarations3 жыл бұрын

    Can’t wait to learn how to press buttons. I have been trying to learn how to press buttons ever since I was born

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    One of my favorite activities!!

  • @seifyasser
    @seifyasser3 жыл бұрын

    Love your desktop wallpaper and contet, all the support from Egypt.

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Thanks so much!

  • @moaothi8405
    @moaothi84053 жыл бұрын

    Thank you dear Justin

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    You're so welcome!

  • @georgekei1575
    @georgekei1575 Жыл бұрын

    Thank you for the very good video. It's great help. The button works great when on a flat surface but when i rotate it to 90 degrees doesn't work properly. Any ideas would be great help

  • @bobdirmish6843
    @bobdirmish6843 Жыл бұрын

    Hey Justin, thanks for the great tutorial. I am working on making this dummy proof and I've discovered that the button works great when pressed softly and right on. However, if you go from underneath or press it really hard, etc. it can move beyond its limits. Any idea on what settings can be used to confine the movement to only up and down the limit specified?

  • @youngchoi1
    @youngchoi12 жыл бұрын

    Thank you!

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    You're welcome!

  • @BartMassee
    @BartMassee3 жыл бұрын

    great, thanks!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    You’re welcome!

  • @ozgenaliekber
    @ozgenaliekber3 жыл бұрын

    Amazing!

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Thanks!

  • @loukenart
    @loukenart3 жыл бұрын

    im exited! can you show in a future video how to make custom hand pose when holding objects?

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Yes! I'm working on perfecting it now and will make a video soon!

  • @loukenart

    @loukenart

    3 жыл бұрын

    @@JustinPBarnett awesome!

  • @hybridalienrob
    @hybridalienrob2 жыл бұрын

    Great video thanks... I'm a total noob, so now looking for another video on "normal unity event stuff" ;)

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Sure thing!

  • @tomu6859
    @tomu6859 Жыл бұрын

    Wowsers, ngl, that was incredibly fast and I feel like I just couldn't follow unless I slowed down the video. Maybe that's just me and how I work but thanks for the tips anyways :)

  • @SkullKrusher017
    @SkullKrusher0172 жыл бұрын

    I want to make this with Augmented Reality, any ideas on how I get it to push down when I can only interact with a touch??

  • @Bricksalive
    @Bricksalive2 жыл бұрын

    Hi! Great tutorial thankyou! I got it working for the test button but for some reason when I do my own button with the buttons local position set to 0 when I hit play its position jumps to 5,1.6,-2 when in scene view it doesn't look like it's move at all. This makes the physics button script not work because the start position was 0 but after 1 or 2 frames it has changed? Any ideas on why it the position changes when I hit play?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Join the discord if you're still having issues and we can help you troubleshoot!

  • @GameBasti
    @GameBasti2 жыл бұрын

    Great video!

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Thanks!

  • @morrisgriebel1366
    @morrisgriebel13663 жыл бұрын

    Hey Justin, first of all I want to thank you a lot for your marvelous work. Your detailed tutorials helped me out plenty of times! Altough I'm currently a little bit stuck. I'm trying to use the physical buttons as a way to navigate through my UI ((not physical) buttons). I'm trying to have one button to make me navigate upwards in the UI, one to navigate downwards in the UI and one to submit the choice. I just cant get it working... Maybe you have any Idea on solving this issue? :)

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Thanks so much! Join the discord if you're still having issues and we can help you troubleshoot!

  • @Diedamni69
    @Diedamni693 жыл бұрын

    Cool video! I'll have to try this. I'm also trying to do a steering wheel and a throttle lever for speed to drive a vehicle in vr using hinge joints, but once the vehicle starts moving, these objects with joints gets effected by physics starts to wobble. Do you know how to use these joints in a moving objects? Or is configurable joint better option in general?

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    hmmm my first though is to increase the dampening required to move any of the joints. Hinges should work fine for that. A configurable joint just gives you more flexibility with how the joint moves, but I don't think it'd be required for your case. You could also do some kind of collision check and lock the joint except when the player is colliding with it, something like that. Let me know if you figure it out!

  • @Maite-AileenBrandt

    @Maite-AileenBrandt

    2 жыл бұрын

    Thanks for the question, exactly what I desperately needed! :D

  • @114london
    @114london2 жыл бұрын

    Hey Justin, when you're setting up the configurable joint around 4:15, are you referring to the Local OR Global rotation? I'm confused, because they are different in my case, and I don't know which one to take into account.

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Should be local I believe!

  • @learnwithsam200
    @learnwithsam2003 жыл бұрын

    Just...Thank you...A lot!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    You're SO welcome!

  • @cyberstar251
    @cyberstar2512 жыл бұрын

    could we get a variant of this for vrchat's udon scripts?

  • @josh-dane
    @josh-dane2 жыл бұрын

    Thanks man! Great tutorial. HELP: Anyone know how I can make this button show the "next slide" of a panel? In my case, I'm using UI canvases and I have them on a panel. I want the "Next Slide" button (the one from this tutorial) to proceed to the next slide. So, I'm wondering how I can get this to happen. Any ideas? Thanks!

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    You'll have to make a little script that you tie to the button press event that progresses to the next slide whenever it's called

  • @dirtyleon
    @dirtyleon3 жыл бұрын

    Justin why does your code editor have hints like for the line "Debug.Log([message:] " ")", it tells you that you should put [message] between quote marks?

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    I’m using JetBrains Rider as my IDE, and it gives me nice hints like that!

  • @yakkeDev
    @yakkeDev2 жыл бұрын

    Hello, Great video! I did manage to do something wrong tho. that is I get the released massage when I start the game and pressing the button will not give any more messages. Where could the problem be?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Join the discord and we can help you out there!

  • @jonas5759
    @jonas57592 жыл бұрын

    Thank you for the perfect explaining video! Can I ask, what editor do you use? Visual studio or Visual studio code? And if you are using VS code how do you get the intellisense?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    I use JetBrain’s Rider IDE!

  • @AnthokGaming
    @AnthokGaming3 жыл бұрын

    Wonderful! Just what I was looking for! :) Now to figure out how to get that press to do something. I assume I call the function "OnPressed()" in another script to get it to do something? Any resources or your videos that you can point me to to help this? Thanks again! :)

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    All you have to do is make/use a public method on any game object, then drag that object into the onPressed() event in the inspector and select the method. There's a video about how to do that part on my Patreon! www.patreon.com/justinpbarnett

  • @AnthokGaming

    @AnthokGaming

    3 жыл бұрын

    @@JustinPBarnett excellent thank you! I ended up adding a gameobject “audio” and just dragging that audio into the “on pressed” and selecting the “play()” function within the “on pressed” part. Seems to work wonders! When I rotate the button though, the y axis makes it move out of the “base” I think something is rotating correctly. For this project I am just going to keep the buttons on a horizontal surface.

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    @@AnthokGaming Nice! glad you got it working! Just make sure you rotate the entire button object and not the things inside of it cause that'll mess you up

  • @danielgarciagonzalez2391
    @danielgarciagonzalez23913 жыл бұрын

    Finally a buttonn!!!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Woot woot!

  • @dominikkomar9170
    @dominikkomar91703 жыл бұрын

    Would a similar way apply to drums? I want to make my controllers not go through my drums, so it's not a press but more of a touch/hit...

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Yea! Just do a very small limit to mimic the bounce of a drum, that'd be cool!

  • @Kiddrelax
    @Kiddrelax2 жыл бұрын

    ​Hey im new to unity (Quest 2), and I cant use the hands to push a button, I tried to put box colliders and/or a rigidbody but or it doesnt work or the button flies away, I followed youre tutorial on quest 2 so for hands I have those two big white lasers

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Join the discord and we can help you troubleshoot!

  • @josh-dane
    @josh-dane2 жыл бұрын

    HELP: Any idea why regular rigidbodies won't press the button? I want to give the player a cube to be able to set on the buttons and move between buttons that way. The cubes won't activate the buttons though. They just fall and sit on top without moving the buttons down at all. The Pressed and Released are working though when I manually slide the buttons down in the editor view... Any ideas? EDIT: "Enable Collisions" is on in the Configurable Joint component of the Push object. Still not working :/

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Is either rigidbody’s isKinematic box checked? That would prevent it from using physics

  • @MrAbantaki
    @MrAbantaki2 жыл бұрын

    Yo justin love the vid! I have a problem tho, i cant seem to get it to work with my XR rig. Edit; iam using Oculus and not openXR

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Are you using the OVR plugins? because those don't work with this. If not, join the discord and we can help you out there!

  • @hansranger9751
    @hansranger97513 жыл бұрын

    Hey thank you very nice Video. I have a Problem. I can press the button in de Scene window. But if I try it in VR, it's not working. Do you have any Ideas?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Join the discord if you're still having issues and we can help you troubleshoot!

  • @LordSindoreShadowind
    @LordSindoreShadowind3 жыл бұрын

    Yeah I like it, there is an odd collision error in the console, however I was trying to pull the button up at the time. This could have also been used as an iteractable object to rite? Is there a fix on the cards for the collision between the hands and an object I refer to the object and hand fighting for the controller position, my thought were to disable the collision of the hand so you still had the interaction of collision of the object against other objects.

  • @LordSindoreShadowind

    @LordSindoreShadowind

    3 жыл бұрын

    If this was done with a (for lack of a better word) lock zone, that was a set location on the hand to snap picked up/interacted objects to. I am in now way suggesting snapable zones, just a good fixed position for the object to fit to while held. If would be interesting to know your thoughts on the subject.

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    What's the collision error? That's odd...Yea your fix would work by turning off physics for the hand and forcing the player to pick up an object to press the button with. Doesn't sound too intuitive though.

  • @LordSindoreShadowind

    @LordSindoreShadowind

    3 жыл бұрын

    @@JustinPBarnett that's what I thought, however I don't see how else you could stop the two objects fighting for the same position, so it could just be me looking at it all wrong. The only other idea I had for this would to alow the block or object to push the finders back a bit, to alow for a much more natural look grab, and to apply some way of stopping the grabbed object from, pushing for pole position with the hand. I'm not at my PC at the mo, but I will post the error if I can recreate it.

  • @LordSindoreShadowind

    @LordSindoreShadowind

    3 жыл бұрын

    @@JustinPBarnett I was thinking more of the previous tutorial were you rigged the hand to pick up the cube, with colliders on both cube and hand, not so much for use as a way of pushing the button, next time I'll split my comments to the correct video to avoid confusion. Keep up the good work and I look forward to your next video.

  • @beebix247
    @beebix2472 жыл бұрын

    How are you getting your hand to have collision with the button? Do you make a sphere collider around the hand or a mesh collider for the model that goes on your hand? I have a sphere collider set as a trigger for XR direct interaction, and I have a hand model set as the model prefab.

  • @beebix247

    @beebix247

    2 жыл бұрын

    I ended up putting a physical box collider around my hand

  • @jdlewis79uk
    @jdlewis79uk3 жыл бұрын

    Hi Justin, thank you for another great tutorial! I was just wondering, when it comes to the code, I am getting the following error: 'The name `Math' does not exist in the current context' > I have tried to replace it with 'System.Math'. However when I press play, my console continuously gives me 'Released' debug message (without me pressing the button), and my 'Pressed' action doesn't register on the debug. Do you think the error is linked to this 'math' issue I am having? Thank you :)

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    make sure you have "using System;" at the top in your using statements.

  • @jdlewis79uk

    @jdlewis79uk

    3 жыл бұрын

    @@JustinPBarnett Wow, thank you so much for the quick response, that is really nice of you! I've made that change. I'm still getting the same errors (apart from Math which now works without error log), but maybe it's due to me making an error in writing the code. I'll go over everything again, I'm sure it will work eventually! Again thank you for your tutorials, you're a life savior! Working on a VR project with a local artist, it's all been possible thanks to your tutorials so far!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    @@jdlewis79uk you’re so welcome!! Let me know if you have any other specific questions! Also you can join the discord and post your code in #dev-help if you want someone to look it over!

  • @jdlewis79uk

    @jdlewis79uk

    3 жыл бұрын

    @@JustinPBarnett Thank you for this, I might well do that!

  • @alexandravega9474

    @alexandravega9474

    2 жыл бұрын

    @@JustinPBarnett it workedddddd, i had the same problem, thank you!

  • @shaginvr1223
    @shaginvr12233 жыл бұрын

    i try 2 weeks finding a guid and its the easy!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Glad I could help!

  • @Roockert
    @Roockert2 жыл бұрын

    i dont know what is causing it but it seems like the collision with this joint is fairly inconsistent. i've scripted my own button which does exactly the same which also works on angles without any joints (using dot products to figure out where the button should snap back to / spring back up) and this seems to have no issues with collision as its only a rigidbody moving with physics controlled by a simple script

  • @bigmagictent
    @bigmagictent2 жыл бұрын

    I don't know what's wrong, but after copying your actions the buttons are inert in my version of the project. If I grab them from the Editor window there's resistance when I move them. When I put on VR and try it nothing moves at all.

  • @nikname2560
    @nikname2560 Жыл бұрын

    sorry this is late, but could you make a tutorial with those types of buttons but for keyboard and mouse please

  • @TheMinistryOfJesus
    @TheMinistryOfJesus3 жыл бұрын

    please show me how to use teleportation on to a teleportation point to change game level

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    I've got a video on teleportation! Is this what you're looking for? kzread.info/dash/bejne/layG0K1xkay7g6w.html

  • @riamatapurkar6844
    @riamatapurkar6844 Жыл бұрын

    Hi, so when I add the box collider to push, it gets added away from the red button and not on the red part. When I run the red part disappears. If I add the box collider to the clicker part however it gets pushed up and down but pressed and released don't show up in the console. I'm trying to count the number of presses as well. Any help would be appreciated :D

  • @sonic-th966

    @sonic-th966

    Жыл бұрын

    Are you sure, that the red part really disappears? Or does it get pushed away from an other collider in your scene? Just watch the position of the object. I recommend, that you disable all other gameobjects in your scenes and just let the button on. If it works then you should enable the objects one by one until the red part disappears again.

  • @asolondev
    @asolondev2 жыл бұрын

    I do have a problem: when I use my hand to push down the button in VR, I am able to press it quite far into the base, even though I have a Linear Limit set to a value that shouldn't let it go that far in the configurable joint. Do you have any advice on how to address that?

  • @mw-cf5dr

    @mw-cf5dr

    2 жыл бұрын

    My hands don't seem to affect the button at all, I thought I followed everything in the video but I think I have missed something.

  • @jimmychen0123

    @jimmychen0123

    2 жыл бұрын

    I have the same, any idea to solve this?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Join the discord and we can help you troubleshoot!

  • @Rob-Heaston
    @Rob-Heaston2 жыл бұрын

    Can you recommend a good windows computer for this type of work?

  • @rodneywheeler7764
    @rodneywheeler7764 Жыл бұрын

    Im a little stuck i have a Point Light i would like to turn on and off using this Any help in the youtube world would be appreciated. Do i need to add a Bool Variable With The Point Light attached to a game object then call a if statement saying if button threshold is > than what is set is the proper line of code PointLight.enabled = True or Set.Active

  • @Minecraftler007
    @Minecraftler0072 жыл бұрын

    Thanks for this Video. For everyone having issues with teleporting push buttons and infinite pushability, make shure that the button is not inside of another box collider of another object. This gave quite a headache

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Good tip!

  • @MrRansuil
    @MrRansuil Жыл бұрын

    Hey Justin! I am late to the party, but I didnt really understand your GetValue function and couldn't get it to function properly. The joint is set up correctly, I am sure. When I press the button for the first time it triggers the 'Pressed', and then when I let go it moves up out of the deadzone and then triggers both the released and a new pressed! I think it has something to do with the (local)scale of my button objects? I figured out the math below, which seems to do the trick perfectly. It doesnt use the deadzone var anymore, just the threshold var, which now acts kinda like a percentage. [SerializeField] private float threshold = 0.1f; Vector3 ButtonEndposLocal; private bool _isPressed; private Vector3 _startPos; void Start() { // this is where I figure out the End Y position of the button when it is fully pressed. Vector3 ButtonEndposGlobal = transform.TransformPoint(_startPos) - new Vector3(0, _joint.linearLimit.limit * transform.localScale.y , 0); ButtonEndposLocal = transform.InverseTransformPoint(ButtonEndposGlobal); } void Update() { if (!_isPressed && GetValue() + threshold >= 1f) // from 90% pressed onwards Pressed(); if (_isPressed && GetValue() - threshold

  • @mesmes9424
    @mesmes94242 жыл бұрын

    I just was wondering, Is it a better approach using in the btn script Fixed Update then regular update ?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    FixedUpdate would definitely be better

  • @614bbhyeol3
    @614bbhyeol33 жыл бұрын

    is there a way to put in pics and have them pop out when u click on a component?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Absolutely!

  • @aylaisaacson2581
    @aylaisaacson25812 жыл бұрын

    This was so helpful! Thank you! The only problem I have though is that I keep getting errors saying that ""Math" and "Abs" does not exist in the current context." I'm not sure what this means...

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    I've actually been getting the same error for Math.Clamp... idk what the issue is though. Maybe just a re-compile/restart

  • @jordanstainer8183

    @jordanstainer8183

    2 жыл бұрын

    I had the same problem I fixed it by adding (using System;) at the top hope it works for you too.

  • @RikoF1

    @RikoF1

    2 жыл бұрын

    @@jordanstainer8183 thanks

  • @mariacotuna

    @mariacotuna

    2 жыл бұрын

    @@jordanstainer8183 thanks this worked

  • @ProxCyde

    @ProxCyde

    Жыл бұрын

    I know this is an old comment, but I see a lot of these on the vid. Don't forget to add the 'f'. It's Mathf.Abs, not Math.Abs. Just in case anyone else comes along and are having similar issues.

  • @GhazzalJastaniah
    @GhazzalJastaniah3 жыл бұрын

    hello!! Amazing video, I just have one question, how did you create the button pressing animation and which interactable did you use?

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Didn’t use an animation! Just the configurable joint provided by unity and some code to make the interaction event

  • @watesa6329
    @watesa63292 жыл бұрын

    hi my Unity Show this to me after code:Assets\PhysicsButton.cs(30,27): error CS0103: The name 'GetValue' does not exist in the current context Can you help me to find the problem, thank you!

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Join the discord and we can help you troubleshoot!

  • @carltitusranario5871
    @carltitusranario5871 Жыл бұрын

    how to make it stay pressed and only released if it will be pressed again , thank you

  • @ProdigiaGames
    @ProdigiaGames2 жыл бұрын

    Here I am, one in the morning, building a press button system by the same creator who is one of the ones actually running the VR Jam that I'm using it for. Either that's as strangely humorous as it seems to me, or I really just need some sleep 🤣🥱

  • @carajames5204
    @carajames52044 ай бұрын

    for some reason my console keeps says that its being pressed and unpressed even when nothing is happening, can someone help?

  • @Dainjamouth
    @Dainjamouth2 жыл бұрын

    The code section really confused me so I can no longer continue with the tutorial, mainly because certain parts of my code are not changing colour to what you have they just stay white (UnityEvent, onPressed, onReleased) etc. What am i doing wrong?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Hmmm you may not have your editor connected in Unity. Go to Edit > Preferences > External tools and make sure your editor is selected in the first dropdown

  • @garthflint
    @garthflint2 жыл бұрын

    My hands go into the button, they do not press it. I assume I need to add physics to my hands. Which is the "physics hands" tutorial you mentioned?

  • @omeness23
    @omeness23 Жыл бұрын

    Hi, thank you very much for your video, Justin. Really helped me out there! But, for some reason (eventhough it worked once and no more) now the button gets constantly being pressed, only by playing the scene, without touching anything. I rewatched your video a few times looking what I might be missing and still dont know why it is getting pressed alone. Also sorry for being 2 years late from the video hahaha 😅

  • @mitnick2512

    @mitnick2512

    Жыл бұрын

    Is the rigidbody on the push object still using gravity?

  • @omeness23

    @omeness23

    Жыл бұрын

    @@mitnick2512 Oh, my bad. Saw later it was some object with rigidbody near activating it that I did not saw hahaha. Now it is working perfectly. Thank you very much!

  • @mitnick2512

    @mitnick2512

    Жыл бұрын

    @@omeness23 No problem 👍

  • @BLAS3R
    @BLAS3R3 жыл бұрын

    Has anybody used this to make a multiple-choice question? I'm building an Education VR app for Oculus Quest and I want to use buttons with several buttons labeled A B C D like a multiple-choice question. A little confused on how to implement but I have a base idea. If anybody knows any resources or how to do it themselves I would greatly appreciate it!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    That's a good idea! I'm curious to see if anyone has some good answers

  • @alekjatuszyk4976

    @alekjatuszyk4976

    2 жыл бұрын

    You can make a simple script containing two bools (one for is pressed another for is correct) in another script you make an arrey of script one and loop therw it when you check it make an int a before arrey loops. If is pressed and is correct then do nothing but if is otherwise add one to a int a. After loop check if a is greater than zero. If it is anwser is wrong. If a is 0 player has anwserd correctly. You change is pressed when you press, is correct you chenge in inspector. Hope it helped :)

  • @xAjido
    @xAjido3 жыл бұрын

    I followed the tutorial 100% and the buttons work when on a flat surface and you press from the top, but if I rotate it 90 degrees to put on a wall it no longer works correctly.

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Did you rotate the entire button GameObject or the elements within?

  • @crismarsay
    @crismarsay2 жыл бұрын

    How could i make it that both buttons need to be pressed to trigger the event ?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    You'd have to have a method that gets and saves the button state and also checks the othe button state at the same time

  • @anonymous_alpha6835
    @anonymous_alpha68353 жыл бұрын

    Please do vr lever and joystick

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    It's on my list to do soon!

  • @_Garm_
    @_Garm_3 жыл бұрын

    Ah the pain... 17 more hours to go! :D

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    haha yeaaa, shoulda been out on Wednesday, but it's been one of those weeks...ya know?

  • @_Garm_

    @_Garm_

    3 жыл бұрын

    @@JustinPBarnett no worries more fun tomorrow :D

  • @big_prumpy9634
    @big_prumpy96343 жыл бұрын

    I’m trying to make it so that when I press a button, it hides an object and unhides another. How do I do this?

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Drag the object you want to hide/unhide into the onPressed event in the inspector and then select the enable/disable method. There's a video about how to do this on my Patreon if you want some more info! www.patreon.com/justinpbarnett

  • @big_prumpy9634

    @big_prumpy9634

    3 жыл бұрын

    I’ll check that out now. Thanks Edit: Just subscribed to it, and wow you're a lifesaver. So many tutorials!

  • @fadhlisaufi4049
    @fadhlisaufi40493 жыл бұрын

    i tried to put the button as the children of my controller but it end up going somewhere else everytime i click play to check.I'm assuming because both of my hand and the button has a rigid body causing it to be like that.how can i make the button useable as the children of my controller??i tried to play with the constraint boxes but still not solved 😫😫

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    What are you trying to accomplish by having the button childed to the controller? I'd definitely go with only one rigidbody in that case

  • @fadhlisaufi4049

    @fadhlisaufi4049

    3 жыл бұрын

    @@JustinPBarnett oh i want to make like a profile UI on my left hand controller where i can press on and off the button to open the UI

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    @@fadhlisaufi4049 That'd be cool!

  • @TheEquilibrium66
    @TheEquilibrium663 жыл бұрын

    Sorry Justin, i hope it's not too late to ask... i followed all the video, but my button, when i touch it, remain pressed. there are some tiny spots (over the box collider) where if i press with the physics hands, unblocked the button. p.s sorry for my english, any ideas? thank you for this channel!

  • @TheEquilibrium66

    @TheEquilibrium66

    3 жыл бұрын

    i figured it out!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Glad you figured it out!! What was the fix?

  • @jordanstainer8183
    @jordanstainer81832 жыл бұрын

    I have a problem with mine the button when pressed triggers only once then spams release over and over again how do I fix this?

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    Sounds like you're continuously checking for the release value instead of just once. Either that or there's a 'bouncing' effect happening that's causing it to fire several times

  • @jordanstainer8183

    @jordanstainer8183

    2 жыл бұрын

    @@JustinPBarnett I'll check next time I'm on my computer and update on it.

  • @zonoscopePictures
    @zonoscopePictures3 жыл бұрын

    C# noob here... How would you add a light that switches on/off ? I assume the 3D object with the Unity light needs a C# script attached that tells it to turn on...

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Nope! all you need is to add a light source and then in the onPressed/onReleased event find the light source and select the on/off action!

  • @zonoscopePictures

    @zonoscopePictures

    3 жыл бұрын

    @@JustinPBarnett - thanks for responding- I will try this !!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    @@zonoscopePictures let me know if you get it working!

  • @zonoscopePictures

    @zonoscopePictures

    3 жыл бұрын

    @@JustinPBarnett I've built a button which I can click on , I am trying to use the button to switch a light on and off. I created a Spotlight which animates from 0 intensity to an intensity of 2.4 over 10 frames. I added the Animator ("spotLight1_OFFON") to the Spotlight in the Inspector. In the "Push" attributes of the Button, I added this ("spotLight1_OFFON") to the field under OnPressed() . The other field (in OnPressed) has the options "No Function", and "Animation Clip", I have tried these options and none seem to work. It looks like the options under "Animation Clip" (float frame, bool, etc) are C# terms, but I'm obviously a C# newbie.... If anyone has any insight on how I can hook up my lights to the Button, I'd be grateful!

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    @@zonoscopePictures my suggestion is making another public method that has a bool variable to check if the light is on. Just have this method run every time OnPressed() is performed and then turn the light on or off based off of what the bool variable is.

  • @anthonyparker1589
    @anthonyparker15893 жыл бұрын

    My program runs at start and keeps pressing and unpressing continuously, without physically moving. Everything is set up the same. Any ideas?

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    Hmmmm, is gravity checked on the pushable button part?

  • @anthonyparker1589

    @anthonyparker1589

    3 жыл бұрын

    @@JustinPBarnett With or without gravity it still doesn't function how you had it in the video, but I have all my settings set how you do. Now I made it so it runs once at start, but doesn't click again. The spring works but not the code.

  • @lukaskiefer968
    @lukaskiefer968 Жыл бұрын

    How can you make it work, so you dont need player to press it? I want to make something similar, but I want to just start the game and if you click the button it will react same.

  • @JustinPBarnett

    @JustinPBarnett

    Жыл бұрын

    You could add an animation!

  • @lukaskiefer968

    @lukaskiefer968

    Жыл бұрын

    @@JustinPBarnett yeah just the way I have done it, but used OnMouseDown... thx for reply mate

  • @TechDunk
    @TechDunk3 жыл бұрын

    The button goes through the table for me

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    just gotta tweak those settings! It can be finicky

  • @TechDunk

    @TechDunk

    3 жыл бұрын

    @@JustinPBarnett I tried everything but game up. I use hand tracking so maybe it's because the hand colliders are forced onto a position

  • @jaded4831

    @jaded4831

    2 жыл бұрын

    @@TechDunk Hey dunno if ur still having a problem with this but I had the same problem with using hand tracking so I just added this for a work around: public float minY = -0.01f, maxY = 0f; void Update() { Vector3 currentPosition = transform.localPosition; currentPosition.y = Mathf.Clamp(currentPosition.y, minY, maxY); transform.localPosition = currentPosition; } This just limits the y position of the button so maxY = 0f doesn't let it move up and just tweak minY so it cant move down through the table. It works well enough for me just if you do press it too far down it will teleport up instead of springing back up cuz your hand will be pushing it up.

  • @TechDunk

    @TechDunk

    2 жыл бұрын

    @@jaded4831 ended up with a different UI element, but thanks!

  • @afrakes4510
    @afrakes45102 жыл бұрын

    Seems like you said to scale clicker, but you in fact scaled button. I'm not sure why. My result is i can press the button down beyond the base, but it only counts as a push every so often. Very confusing for such a simple task. This basic project doesnt work for me.

  • @Phosphorus-zr7kl
    @Phosphorus-zr7kl2 ай бұрын

    Is that project on github?

  • @azataiabylbek5262
    @azataiabylbek52622 жыл бұрын

  • @JustinPBarnett

    @JustinPBarnett

    2 жыл бұрын

    🤸‍♂️

  • @MatanNaveh
    @MatanNaveh3 жыл бұрын

    Great video! and it didn't even start..

  • @JustinPBarnett

    @JustinPBarnett

    3 жыл бұрын

    😂😂😂 Thanks for your confidence!

  • @red1monster_
    @red1monster_2 жыл бұрын

    Why does your camera lag so much ?