How to make a VR Button | Unity Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ม.ค. 2025
  • Accelerate your development process with our new, ready to use VR UI PACKAGE, now on the Unity Asset Store! Link for %10 off: assetstore.uni...
    In this video I will teach you how to make a button for VR using Unity. You can use this button to execute any function that you'd like in Unity. I will be testing this button on the Oculus Quest 2.
    COURSE PLAYLIST: • VR Development Full Co...
    Thanks for watching!

ความคิดเห็น • 60

  • @BrownguruVR
    @BrownguruVR ปีที่แล้ว +3

    Please keep making these! They’re so helpful!

    • @RealaryVR
      @RealaryVR  ปีที่แล้ว

      Glad you find them helpful, thanks for the feedback!

  • @Idek_Name
    @Idek_Name 20 วันที่ผ่านมา +1

    can i also make the button spawn a specific something?

  • @BobNThing
    @BobNThing 4 หลายเดือนก่อน

    This will be helpful for my fangame!

  • @dasskla8
    @dasskla8 2 ปีที่แล้ว +2

    Hello, great video. One small problem. It's not registering the exit event, why do you think that is? I can't manage to fix it. Help greatly appreciated.

  • @nobody_there_
    @nobody_there_ 10 หลายเดือนก่อน

    Hello, does your button can work with any hand system ? or it need to be YOUR system ? cheers

  • @khalidmubashshir8748
    @khalidmubashshir8748 7 หลายเดือนก่อน

    Hi,
    I am quite new to the VR and just started. I followed the tutorial fully but the spawned sphere passes through the floor. I checked the collider setup, collision detection by adding it to the rigidbody in the sphere but nothing is working. Any body facing similar problems or solved this kind of problem?

  • @shubhanshushukla7358
    @shubhanshushukla7358 ปีที่แล้ว +1

    My Sphere is falling through the ground in VR but works in Unity Editor, What to do?

  • @Pawixior
    @Pawixior 2 ปีที่แล้ว

    Thanks for the help! Good tutorial.

    • @RealaryVR
      @RealaryVR  2 ปีที่แล้ว

      Thanks Pawel!

  • @UU-gl1hd
    @UU-gl1hd 2 ปีที่แล้ว

    Do you know how can I stop playing the sound when I push another button (which is the same one with this one)? So there are two buttons, one for playing and the other for pausing or stop. I am struggling out the script with it

  • @mariacotuna
    @mariacotuna 2 ปีที่แล้ว +1

    Hiya, love this tutorial!!
    I am having an issue with the Press, after it is used once the object disappears, but the function remains? Any idea what may be causing this? Thanks

    • @ashfaqmuhammed8135
      @ashfaqmuhammed8135 2 ปีที่แล้ว

      any solution?

    • @ambyn9495
      @ambyn9495 2 ปีที่แล้ว

      @@ashfaqmuhammed8135 Increase the height of press gameobject. its probably smaller then the transform position of the button which on press will move inside the base and will seem as if it has dissappeared. hope it helps.

    • @ambyn9495
      @ambyn9495 2 ปีที่แล้ว

      Increase the height of press gameobject. its probably smaller then the transform position of the button which on press will move inside the base and will seem as if it has dissappeared. hope it helps.

  • @marklaubenheimer3596
    @marklaubenheimer3596 2 ปีที่แล้ว

    how do i get the sphere function to run ONLY when i press the button? currently when you press play it automatically runs the function.

  • @gizmobly350
    @gizmobly350 3 ปีที่แล้ว +2

    Cool! Nice tutorial. Simple, clean, and effective.

  • @GargonStudios
    @GargonStudios 2 ปีที่แล้ว

    the ontrigger enter and exit executes both once per frame when my hands are inside the collider

  • @6carlos
    @6carlos 3 ปีที่แล้ว

    Hey! Can you please make a video on how to make a working gun, or a dummy. Love your vids!

    • @RealaryVR
      @RealaryVR  3 ปีที่แล้ว

      Thanks! Yes, it will be coming out soon!

  • @amanyddv
    @amanyddv 2 ปีที่แล้ว

    I am getting a error ( virtual button can not be created INVALID_AREA) while creating virtual button, can you please tell me what should I do to solve this error .

  • @eugenephilipcapiton9561
    @eugenephilipcapiton9561 2 ปีที่แล้ว

    Can you make this work with using only Ray interactor?

  • @AhimsaCreative
    @AhimsaCreative 2 ปีที่แล้ว

    HI i'm wondering why my script doesn't have the Events area when i use this same script. thanks - nice tutorial

    • @AhimsaCreative
      @AhimsaCreative 2 ปีที่แล้ว

      oh.. after restart it seems events worked. I did have to delete the "Invoke" section as unity wouldn't play with in there

    • @RealaryVR
      @RealaryVR  2 ปีที่แล้ว +1

      @@AhimsaCreative Glad it worked! Sometimes you need to minimize Unity and then open it so the code compiles and the events show in the inspector. Otherwise, the scripts should work as is and Invoke should work so you probably have another problem.

  • @user-ry6xo8fw1x
    @user-ry6xo8fw1x ปีที่แล้ว

    The collusion happened only when I move my body towards the button but the my hands not working, can you show us your hand Rigidbody settings

    • @haachamachama7
      @haachamachama7 ปีที่แล้ว

      Should work if your hands have any collider on them.

    • @Shayrin2
      @Shayrin2 ปีที่แล้ว

      no need for rigibody. If anything that's more likely to mess with your hands. Just make sure they have a collider on them.

  • @WaiHanLim
    @WaiHanLim 2 ปีที่แล้ว

    How to make it prevent from spamming?

  • @nathaliagomez3431
    @nathaliagomez3431 2 ปีที่แล้ว

    Great tutorial! works as expected. I couldnt make it work with any other OVR rig though, it only works with the CustomHands with the OVR grabber in it. Even if I use other hands and copy the children of the CustomHands (the ones that come in the oculus integration pack, the ones you also use in the video) it doesnt work, it only works with the CustomHands. Does anyone have any idea why

    • @josh879879
      @josh879879 ปีที่แล้ว

      any luck?

    • @R3troBlue
      @R3troBlue ปีที่แล้ว

      @@josh879879 Hey, Not sure if you already fixed it or not, but for me personally the issue was with the Mesh Collider. Make sure in the Mesh Collider component, make sure beside "Mesh" the box is filled with the object's mesh, because mine was set to none by default.

    • @josh879879
      @josh879879 ปีที่แล้ว

      @@R3troBlue Thanks alot Retro!!

  • @ScareFire
    @ScareFire 3 ปีที่แล้ว

    The reason you're not making is about pushing the button but just passing the finger on it, is it about performances ?

    • @RealaryVR
      @RealaryVR  3 ปีที่แล้ว

      Hi, you could definitely make it to be pushed and be more physics based. I made it this way to keep it simple!

  • @dedsec1175
    @dedsec1175 2 ปีที่แล้ว +1

    can you give the script ?

  • @vr_connoisseur
    @vr_connoisseur 2 ปีที่แล้ว

    Hi!, would this work if I were to attach the button to a controller?

    • @RealaryVR
      @RealaryVR  2 ปีที่แล้ว +1

      Yes, I have tried that before and it worked. Just put it under one of the hand anchors.

  • @crecker1850
    @crecker1850 2 ปีที่แล้ว +2

    when i press the button it just stays down

    • @gremlinfrend
      @gremlinfrend 2 ปีที่แล้ว

      Same issue for me

    • @ambyn9495
      @ambyn9495 2 ปีที่แล้ว

      @@gremlinfrend just increase the height of the press this might help.

    • @ambyn9495
      @ambyn9495 2 ปีที่แล้ว

      just increase the height of the press this might help.

    • @forouzan_fn
      @forouzan_fn ปีที่แล้ว

      if(other.gameObject == presser)

  • @ognjenidjecak76
    @ognjenidjecak76 2 ปีที่แล้ว

    Sound link?

  • @safdardeveloper3804
    @safdardeveloper3804 2 ปีที่แล้ว +1

    Hi, for me is not working, when I test it, the button gets pressed as I approach it. It stays pressed even if I move away. Please help me.

  • @Test-ff2cx
    @Test-ff2cx 2 ปีที่แล้ว

    My hands got disappeared while changing the layer and button didn't showed up

    • @ambyn9495
      @ambyn9495 2 ปีที่แล้ว +1

      in camera culling active the layers so you can see the objects in play mode. hope it helps.

  • @Gibbons-official
    @Gibbons-official ปีที่แล้ว +1

    if you can can i have the script please

  • @potatoistomato4938
    @potatoistomato4938 ปีที่แล้ว

    Help

  • @esmeemarch612
    @esmeemarch612 9 หลายเดือนก่อน +5

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Events;
    public class ButtonVR : MonoBehaviour
    {
    public GameObject button;
    public UnityEvent onPress;
    public UnityEvent onRelease;
    GameObject presser;
    AudioSource sound;
    bool isPressed;
    // Start is called before the first frame update
    void Start()
    {
    sound = GetComponent();
    isPressed = false;
    }
    private void OnTriggerEnter(Collider other)
    {
    if (!isPressed) {
    button.transform.localPosition = new Vector3 (0, 0.003f, 0);
    presser = other.gameObject;
    onPress.Invoke ();
    sound.Play ();
    isPressed = true;
    }
    }
    private void OnTriggerExit(Collider other)
    {
    if (other.gameObject == presser) {
    button.transform.localPosition = new Vector3(0, 0.05f, 0);
    onRelease.Invoke ();
    isPressed=false;
    }
    }
    public void SpawnSphere()
    {
    GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
    sphere.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
    sphere.transform.localPosition = new Vector3(0, 1, 2);
    sphere.AddComponent();
    }
    }

    • @khalidmubashshir8748
      @khalidmubashshir8748 7 หลายเดือนก่อน

      Hi,
      Thank you for the script. I followed the tutorial but the spawned sphere kept falling through the floor. Can you please help?

    • @esmeemarch612
      @esmeemarch612 7 หลายเดือนก่อน

      @@khalidmubashshir8748 Try not to use gravity for the sphere

    • @khalidmubashshir8748
      @khalidmubashshir8748 7 หลายเดือนก่อน

      @@esmeemarch612 i tried not using the gravity but then the sphere gets stuck in the space and no other spheres are visible.
      I used the script that you gave but the spheres fall right through the floor.

  • @haachamachama7
    @haachamachama7 ปีที่แล้ว

    I'm sorry, i try to refrain from making comments but this tutorial is horrible. Spent too much time explaining useless stuff(like dude, the button model shouldn't take you 3 minutes to explain, just make it before the tutorial lol), and all the tutorial is is how to make a physical button, nothing really VR related at all. I coulda figured that out easily, my friend... And it's not really written too well in the first place, you should be checking for tags on trigger enter or the specific controller component, or anything and everything that hits the button will trigger it.

    • @diariocancun3698
      @diariocancun3698 4 หลายเดือนก่อน

      So create your own channel and explain it though. I guess you can make it really nice, good luck!!

    • @haachamachama7
      @haachamachama7 4 หลายเดือนก่อน

      @@diariocancun3698 I could. I used to make tutorials, actually, i removed them all because i had my ex's name in my old company's name lol
      Certainly could make a 2 minute video explaining how to make a cylinder that reacts to being pressed down