How to Make a VR Game in Unity 2022 - PART 5 - Hover, Grab and Use Interactable

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

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

  • @ValemTutorials
    @ValemTutorials  2 года назад +112

    No cubes were harmed in the making of this video.

    • @I_am_thing
      @I_am_thing 2 года назад +1

      I am getting a namespace error

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

      Hi i just notice when i grab the cube and moove my controller close to my body so close to my hitbox the cube is coldie whit my hitbox and i fly
      je pense que tu es français alors au cas où la hitbox du cube entre en collision avec la hitbox de mon personnage et me fait donc voler, j'aimerais savoir si c'est possible de corriger ça? en tous cas super vidéo sinon :D

    • @SgtMacKerZ
      @SgtMacKerZ Год назад +2

      @@prso5587 Looks like this started off in English and slowly trailed off into French? :)

    • @prso5587
      @prso5587 Год назад +1

      @@SgtMacKerZ yes because i think this guy is french like me x)

    • @SgtMacKerZ
      @SgtMacKerZ Год назад +1

      @@prso5587 I thought it started English and slowly started changing to French as it went on. But now I think you just wrote it in English and in French as well afterwards? My mistake

  • @SSnapse
    @SSnapse 2 года назад +32

    Script for the gun (make sure the name of the script is the same as the name in the video):
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.XR.Interaction.Toolkit;
    public class FireBulletOnActivate : MonoBehaviour
    {
    public GameObject bullet;
    public Transform spawnPoint;
    public float fireSpeed = 20;
    // Start is called before the first frame update
    void Start()
    {
    XRGrabInteractable grabbable = GetComponent();
    grabbable.activated.AddListener(FireBullet);
    }
    // Update is called once per frame
    void Update()
    {

    }
    public void FireBullet(ActivateEventArgs arg)
    {
    GameObject spawnedBullet = Instantiate(bullet);
    spawnedBullet.transform.position = spawnPoint.position;
    spawnedBullet.GetComponent().velocity = spawnPoint.forward * fireSpeed;
    Destroy(spawnedBullet, 5);
    }
    }

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

      thank you

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

      it says the script cant be loaded because of compiling errors any ideas?

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

      @@alexanderbirdie125 Are you sure the name of the script is the same as shown in the video?

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

      THANKS!

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

      OM, Thank you very much!

  • @givemepen0
    @givemepen0 2 года назад +35

    Loving this series, it's been an absolute god send for me

  • @SoundEffekts2
    @SoundEffekts2 Год назад +57

    If anyone is having trouble with their gloves not picking up/selecting anything- make sure to check off the "Is Trigger" box on each of your gloves! Took me four hours to figure that out

    • @MatanNaveh
      @MatanNaveh Год назад +1

      I had the same problem, thanks man!

    • @Lordsi
      @Lordsi Год назад +1

      Could you explain this further please?
      The left hand and right hand Sphere collider, turn of the is trigger?

    • @GamerCreacher
      @GamerCreacher Год назад +1

      omg thank you i spent about 1 hour

    • @Alm0nd-p8o
      @Alm0nd-p8o Год назад

      You're a genius

    • @Umbra7861
      @Umbra7861 Год назад +2

      You might also have an issue of your collider not being centered on your controller object. Make sure your controller AND the collider are starting at the same position (0,0,0).

  • @AriyaBayat
    @AriyaBayat 10 месяцев назад +11

    If attach transform is not working for you:
    go to the game object who's attach transform you'd like to manipulate during runtime
    add an XR Single Grab Free Transformer component to it
    inside your XR Grab Interactable component, scroll to the bottom until you see Grab Transformers Configuration and expand it
    add an item to the Single Grab Transformers list and drag the XR Single Grab Free Transformer component you just added to that new empty slot
    run the game and manipulate the attach point to your liking
    you can then reverse all of this to get things back to "normal"
    was driving me nuts as well, hope this helps, good luck!

    • @marijnisn00b
      @marijnisn00b 9 месяцев назад

      Thank you so much! I was wondering why I couldn't do that

    • @MandralidaruzDev
      @MandralidaruzDev 6 месяцев назад

      Perfect!

  • @petermcrory5194
    @petermcrory5194 2 года назад +7

    Great series Valem! Thanks so much for this new course. :) Super cool you're sponsored by Unity!

  • @jaifien7356
    @jaifien7356 2 года назад +16

    You should do a tutorial series on Ultimate XR for unity. It’s a new VR toolkit that was released last month, free for commercial use

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

    I am glad you fixed the collision bug at the end because I knew it was going to be a problem as I have dealt with it before and wasn't sure you would cover it. Layers are great.

  •  2 года назад +8

    13:34 you should not check equality on float. And you are checking an analog input (trigger) which may never be 0 (zero). You better check it with a threshold something like x < 0.1f . Great tutorial by the way, saved tons of time. Thank you.

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

      Good remarks ! Better play it safe you're right

    • @guidocomba
      @guidocomba 2 года назад +1

      HI hello i have the same issue, i can take the gun but not move by teleport enymore. How can i fix this? i change the value of == 0 to this < 0.1f but dosent work. Im using HTC vive controllers. By the way awsome tutorials @Valem Tutorials.

  • @Noah-sw5xw
    @Noah-sw5xw 2 года назад +3

    wuuuuhhh new episode

  • @skudgee2
    @skudgee2 Год назад +2

    Your videos are addictive ! Can't believe it's already ep.5

  • @IronBee_official
    @IronBee_official Год назад +2

    I did the script myself, Its so fun, I start to understand how things work

  • @boogiehasfun
    @boogiehasfun 5 месяцев назад +1

    something i learned is that the ground should have a box collider, since sometimes the cubes can phase through the ground if it goes straight down

  • @Arashi256
    @Arashi256 2 года назад +6

    I assume the issue evident at the very end of the video where the attach transform only works with one hand (the right in your case) will be solved in the next video? My attach transform for the pistol looks fine for the right hand, but is too far right when holding in the left hand, so the hand is not centered on the grip of the pistol.

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

      Yes! I am having the same problem, have you found anything out??

    • @Arashi256
      @Arashi256 Год назад +1

      @@carsonlohr2781 Hey - in the next video he creates a class that inherits from the base Grabbable class and can attach a transform for each hand so you can modify each to each hand. Hit me up if you can't find it and I can send you the code, no worries.

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

    Excellent video for studying VR development! Everything was done. Thank you!

  • @Ony_
    @Ony_ Год назад +3

    2:01 when adding the XR direct interactor i get an error messege saying "Can't add XRDirectInteractor to right controller becaus a XRRay Interactor is already added to the game object!
    a game object can only contain one XRbaseInteractor component."

    • @Vs-ub4tq
      @Vs-ub4tq Год назад

      Deleting the line indicators or whatever they're called seems to fix the issue.

    • @ITZNICKYYYY
      @ITZNICKYYYY 9 месяцев назад

      @@Vs-ub4tqhow?

  • @Sushanth-m3o
    @Sushanth-m3o Год назад +2

    For those who have motion of character ,throwing character away while picking box,make sure you reduce your capsule collider radius

  • @sullina3
    @sullina3 Год назад +1

    the "live editing" of the attach point you're doing at 8:45 isn't working for me at all. I can edit the attach point when the program isn't running, but that's requiring a lot of trial and error...

    • @SuzumaIkimura
      @SuzumaIkimura 9 месяцев назад

      Hey man, do you have any answer to this problem, because I have the same situation and after 30 minutes I put my model in the right position, but it takes a long time.

  • @jya-pc4821
    @jya-pc4821 9 месяцев назад +2

    I've been following all the previous tutorials and when I get to the 1:58 mark and add the XR Direct Interactor it will not let me because I already have the XR Ray Interactor. Should I delete one of them? Would that not remove the teleportation rays I made before?

  • @skortle4529
    @skortle4529 2 года назад +5

    Hey, I followed the tutorial and I'm having an issue at 12:19, For some reason the Bullet, Spawn Point, and Fire Speed options won't come up, Any way to fix this?

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

      I have the same problem, did you ever fix it?

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

      @@thenoseguy Sadly not, I've given up on my VR Project for now :(

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

      @@skortle4529 I figured it out. Just gimme a sec to remember how I did it.

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

      @@skortle4529 What I did was I copied the code exactly without copy and pasting anything. I got it wrong the first time because I copied and pasted some random guy's "copy" of the code and it didn't work. Just have Visual Studio and RUclips open at the same time.

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

      make Shure there are no errors and that all of the code as a ; at the end of the line

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

    Hi, how were you able to move the attach transform while you were not in your headset at 8:57.
    Whenever i take off my headset the screen blacks and the game kinda pauses itself

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

      put ur finger on the things that say 1 2 or 3 and it tricks it into thinking u ahve ur headset on

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

      @@HalfTayem Thank you :)

  • @SwordOfShaolin
    @SwordOfShaolin 2 года назад +1

    Thanks Valem! These have been great tutorials.

  • @OramiIT
    @OramiIT 9 месяцев назад +1

    @ValemTutorials, I have noticed that right hand/left hand requires different attach points. Is there a built in way to select which attach point is used (I created two per item) based on what hand is grabbing the item?

  • @muhammadshidiq451
    @muhammadshidiq451 Год назад +1

    so cool thanks mr Valem

  • @vasurabadiya2436
    @vasurabadiya2436 Год назад +1

    Very informative thanks for this amazing video brother.

  • @dreamrender5587
    @dreamrender5587 2 года назад +5

    Hello Valem. I am a huge fan of yours and very thankful for you. Would It be possible to make a tutorial on inventory? This would be much appreciated. Thanks, Henry

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

      Hi henry thanks for watching the video, I'll take note on that idea it can be nice for a future tutorial thank you. :)

  • @Grace_RR
    @Grace_RR Год назад +3

    I have a problem, 4:58 when I grab the cube it doesn't turn yellow. it turns white when i touch the cube but doesn't turn yellow when i grab the cube

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

      I had a similar problem. For some reason I had a Direct Interactor as a child component of my hands, which did not work. I deleted those and multi selected "Left Hand" "Right Hand", then added the XR Direct Interactor and the Sphere Collider. Now it's listening to my hands.
      In other words, double check your XR Direct Interactor and Sphere Collider are directly on the Hand components.

  • @EzraVFX
    @EzraVFX 2 года назад +5

    Great tutorial as always, is there also a way to make a two hand grab or maybe even a custom grip, for exampale if you hold a gun it put the hand on the trigger etc.

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

      Custom hand pose for will be cover soon ! For two hands grab I've made a previous video on the subject here : ruclips.net/video/Ie0-oKN3Lq0/видео.html
      But I know that Unity is planning on adding it in future update of the unity xr toolkit :)

    • @EzraVFX
      @EzraVFX 2 года назад +1

      Ah thank you ill defenitly take a look a the two hand tutorial!

  • @Yolakx
    @Yolakx Год назад +8

    Code for teleportation
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.XR.Interaction.Toolkit;
    using UnityEngine.InputSystem;
    public class ActivateTeleportationRay : MonoBehaviour
    {
    public GameObject leftTeleportation;
    public GameObject rightTeleportation;
    public InputActionProperty leftActivate;
    public InputActionProperty rightActivate;
    public InputActionProperty leftCancel;
    public InputActionProperty rightCancel;
    // Update is called once per frame
    void Update()
    {
    leftTeleportation.SetActive(leftCancel.action.ReadValue() == 0 && leftActivate.action.ReadValue() > 0.1f);
    rightTeleportation.SetActive(rightCancel.action.ReadValue() == 0 && rightActivate.action.ReadValue() > 0.1f);
    }
    }
    Be sure to have the same names as in the video.

    • @sarkkitehti3544
      @sarkkitehti3544 Год назад +1

      Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you...

    • @PixelGame_
      @PixelGame_ 10 месяцев назад +1

      Thank YOU SO MUCH BROOOOOOOOOO

  • @RigidDecay
    @RigidDecay 2 года назад +5

    Would you happen to know if there is a way to change how the hand grips around whatever object you are trying to grab?

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

      i think it grabs the center, so u have to make the center of the collider where the hand goes (tbh im a noob at unity but ig try it)

  • @Bill-us8nn
    @Bill-us8nn 2 года назад +2

    Great video, thanks so much. Would you say this updated Unity VR solution is better than the one in your older video?

  • @NoahVR4567
    @NoahVR4567 2 года назад +1

    i love this im actually making a vr game thanks for the help man

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

    Stuck at 4:43 ... same as a lot of other people, can't seem to get the cube to recognize I am touching it or hovering over it. I made sure to have both hands as triggers and I do have the XR Interaction manager...

    • @tylerwalker7220
      @tylerwalker7220 Год назад +2

      Okay so I fixed my issue which might be a special case. I am on on the newer version of the 3d build and using the Oculus 2 folder that was provided with the series, the controllers came preset with a bunch of other components, but they got in the way. When trying to add the xr direct controller, it would say there was already one in the scene, so all you have to do is clear the components out of each controller. Do so by pressing the 3 dots by each component and pressing Remove Component.
      At 2:24 you can see for each controller there should only be 4 components, - transform, xr controller (action based), xr direct controller, and sphere collider.
      All you have to do is delete everything until you have transform, xr controller (action based), and sphere collider. At this point, just re-add the xr direct controller.

  • @spookyflower3737
    @spookyflower3737 2 года назад +1

    i need some help whenever i get too close with my hands to an object i move a little bit backwards is there any way to fix it

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

      might be late but for me my fix was decreasing the size of the radius on the character controller.

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

    I can't fire the bullet...i have problem with script

  • @taimourkhan3410
    @taimourkhan3410 5 месяцев назад

    Great tutorial, helps a lot.

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

    timing 10:13 not working with meta All-in-one last lib..

  • @kaloshabuthapa3284
    @kaloshabuthapa3284 Год назад +1

    3:25 as soon as I add the XR direct interaction 999+ errors are saying "NullReferenceException: Object reference not set to an instance of an object UnityEngine.XR.Interaction.Toolkit.XRInteractorLineVisual.UpdateCurrentHitInfo ()" did anyone face this? cit would really help me. I cannot even play it

  • @r4ndom-here
    @r4ndom-here 3 месяца назад

    is there a way to change the trigger/button that you have to use for the grabbing system? Love your tutorials :D

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

    12:20 the options under the fire bullet on activate aren’t showing up for me. How do fix this?

  • @Alejandro-yq6oy
    @Alejandro-yq6oy 2 года назад +1

    Why when I put an object that I take with my hand, does it lift or move me?

  • @stryker2k2
    @stryker2k2 Год назад +3

    Whenever I grab the cube, I get launched a thousand miles into the air. Has anyone else ran into that issue?

    • @stryker2k2
      @stryker2k2 Год назад +2

      I figured it out thanks to an earlier comment (sorta). The cube was colliding with my body, sending it flying. So I put the cube and my body on two separate layers then unchecked where the met on the Physics matrix.

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

      @@stryker2k2 im having the same problem, i made an XRorigin layer and left the cube on default, but what do you mena by "then unchecked where the met on the Physics matrix." because I want to fix this issue but dont understand what that meant.

  • @KlaudiaBereczki
    @KlaudiaBereczki Год назад +2

    Hi! Your tutorial is super useful, thank you! :)
    I have a problem I could not fix though - I grab my weapon, let it go, grab again - works perfectly. But once I shoot, I cannot grab it again. Do you have any idea, why it could happen? I made a sci-fi scene with shootable ships, but the grabbing and shooting mechanisms are the same as yours.

  • @Sliceofbread418
    @Sliceofbread418 Год назад +1

    hey, is that normal that when i try to grab an object the grab isn't grabbing but the pinch is grabing, how do i make some objects pinchable and other grabbable ?

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

    Hey, could you teach us how to code a sword like in Blade and Sorcery?

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

      Would be nice :) chop some trees in jungle

  • @lennardheijde5668
    @lennardheijde5668 9 месяцев назад

    HELP! When i add the activate teleportation ray script i cant drag anything into it, it is only one line and its the script. Now i cant go in to playmode and it says it is missing ILineRendareple ??? HELPP 0:45

  • @petermcrory5194
    @petermcrory5194 2 года назад +17

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.XR.Interaction.Toolkit;
    using UnityEngine.InputSystem;
    public class ActivateTeleportationRay : MonoBehaviour
    {
    public GameObject leftTeleportation;
    public GameObject rightTeleportation;
    public InputActionProperty leftActivate;
    public InputActionProperty rightActivate;
    // Update is called once per frame
    void Update()
    {
    leftTeleportation.SetActive(leftActivate.action.ReadValue() > 0.1f);
    rightTeleportation.SetActive(rightActivate.action.ReadValue() > 0.1f);
    }
    }

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

      Thank you boss

    • @reflexclutch1571
      @reflexclutch1571 2 года назад +1

      You are the best, I thought I was going crazy it wasn't working for me

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

      @@reflexclutch1571 did you succeed with the bullet script ?

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

      ty

    • @Mr.Frenzyguy
      @Mr.Frenzyguy Год назад +1

      @@reflexclutch1571 Had the same exact script wasn't working, copy paste, it worked....wtf ahahah (I know it's 1 yr later but this guide is still super useless)

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

    can you make a tutorial on how to make the force in unity like in the oculus game Vader Immortal?

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

      Interesting topic I'll look into it :) thanks for watching

  • @cloudd_08
    @cloudd_08 Год назад +1

    How do I edit the attatch point for both hands? For my left hand the gun position is perfect but it makes it worse when I grab it with my right hand.

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

      Yes! have you found anything?? I cant find anything

    • @cloudd_08
      @cloudd_08 Год назад +1

      @@carsonlohr2781 So to fix this go to the attach point you have already created scroll down until you find a checkbox that says something like “dynamic attach”

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

      @@cloudd_08 where do i find that

  • @matthewduncanson8744
    @matthewduncanson8744 Год назад +3

    how do i get the XR Interaction Manager?

    • @tianzhi_he
      @tianzhi_he 9 месяцев назад +1

      Go to Window - Package Manager (Packages: Unity Registry) - XR Interaction Toolkit (2.5.2) - Samples - Hands Interaction Demo - Click Import, then in the HandsDemoScene, you should be able to find the XR Interaction Manager under the "XR Interaction Hands Setup", you will need to copy paste it into your own Scene. Hope this can help you, took me so long to fix this. I think it's the XR Interaction Toolkit difference that causes the problem. 🧐

  • @OjamaJuice
    @OjamaJuice 2 года назад +1

    super helpful tutorial. do you plan on making a video on how to make the player jump?

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

      Maybe in a future video dedicated to jumping in VR, I think it's interesting how with VR you can actually jump using something else than just the press of a button.
      Like press + moving both hands up like in lot of game.

  • @SephirothinLEGO
    @SephirothinLEGO Год назад +1

    the trick with moving the attach point while holding the gun doesnt work for me, the attach point works but i just cant do the trick

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

      Same for me, it only moves the attach point but the pistol is not moving, hence i have to let go and grab again the pistol so I can know if now the attach point is positioned correctly.

  • @StatusTechDev
    @StatusTechDev Год назад +1

    For the Fire Bullet script, can someone make it so they dissappear after colliding with something else, I have tried attempting this for so long yet it doesn't work. Help much appreciated.

    • @blackmagegamestudio
      @blackmagegamestudio Год назад +2

      You wouldn't add that to the Fire Bullet script. You would attach a script to the bullet prefab. The below script should help you out... Basically in the OnCollisionEnter function, you check to see what the bullet collided with. We need an exception for the pistol (you could make this more items too for more gun types). So long as it passes the IF check, then we call the Destroy function on the gameObject that the script is attached to (ie the bullets).
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class DestroyOnCollision : MonoBehaviour
      {
      void OnCollisionEnter(Collision collision)
      {
      if (collision.gameObject.name != "pistol")
      {
      Destroy(gameObject);
      }
      }
      }

    • @StatusTechDev
      @StatusTechDev Год назад +2

      @@blackmagegamestudio oh I already got this working, thank you though!

    • @blackmagegamestudio
      @blackmagegamestudio Год назад +1

      @@StatusTechDev I figured since the post was a month old... BUT... dropped the comment in case someone else has the same question!

  • @Sam-by3jq
    @Sam-by3jq 2 года назад +3

    I've gone through the whole series and it's awesome and things are working great but I have one issue.
    While holding an object in one hand I am still able to grab it with the other, which makes some weird movement happen since the item is trying to match both hands, how would I fix this?

    • @carsonlohr2781
      @carsonlohr2781 Год назад +1

      If you get a reply let me know.

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

      @@carsonlohr2781 I have a solution that works. Might not be the most elegant but it isn't too bad.
      1. create an Attach Point for both Right and Left hands (attached to the Pistol object). Remember to adjust the values when playing BUT copy them when not playing.
      2. Either add a second script to the pistol or extend the Fire Bullet On Activate (should prob be its own script)
      3. The script will need public variables for Left/Right Attach Points and corresponding XR Direct Interactors. Entire script will be at the end to keep the instructions at the top!
      4. Drag each of the GameObjects (attach points & interactors for both right and left hands) into the exposed variable slots in the editor.
      5. Run the game and see that it works. For fun, I duplicated the pistol so i could dual wield!
      Here's the script I currently have:
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      using UnityEngine.XR.Interaction.Toolkit;
      public class FireBulletOnActivate : MonoBehaviour
      {
      public GameObject bullet;
      public Transform spawnPoint;
      public float fireSpeed = 20;
      public Transform leftHandAttachPoint;
      public Transform rightHandAttachPoint;
      public XRDirectInteractor LeftHand;
      public XRDirectInteractor RightHand;
      XRGrabInteractable grabbable;
      void Start()
      {
      grabbable = GetComponent();
      grabbable.activated.AddListener(FireBullet);
      grabbable.selectEntered.AddListener(UpdatePosition);
      }
      public void UpdatePosition(SelectEnterEventArgs arg)
      {
      Object selectorHand = (Object) arg.interactableObject.firstInteractorSelecting;
      if (selectorHand == LeftHand)
      {
      grabbable.attachTransform = leftHandAttachPoint;
      }
      else if (selectorHand == RightHand)
      {
      grabbable.attachTransform = rightHandAttachPoint;
      }
      else
      {
      Debug.Log("Something's Broken");
      }
      }
      public void FireBullet(ActivateEventArgs arg)
      {
      GameObject spawnedBullet = Instantiate(bullet);
      spawnedBullet.transform.position = spawnPoint.position;
      spawnedBullet.GetComponent().velocity = spawnPoint.forward * fireSpeed;
      Destroy(spawnedBullet, 5);
      }
      }

  • @tommythegoat
    @tommythegoat Год назад +1

    Hi, I was wondering if it is normal for my oculus to like when I am testing my unity game I know this should not be right because I have a very new PC and it works fine playing any other game on oculus but once I test out my game. It likes uncontrollably.

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

    I run into two problems:
    -> When I grab the pistol it seems to move if I use the right analog stick.
    For some reason the PistolObject uses the XR interaction Manager to move I believe.
    -> I am not able to grab the gun anymore. Even if delete the pistol and put it back in. Create a Colider and the xr grab interactible. it's broken.
    EDIT: I performed the seperation between Player Layer and Interactible layer, but still have this issue.

  • @aasciutti
    @aasciutti 7 месяцев назад

    I'm having problemas with the Attach Point. It creates an attach point in the Right Hand controller, and it uses it instead of the empty object I created. But this attach point only appears in Play mode, so I can't add it as attach point to the pistol.

  • @Arashi256
    @Arashi256 2 года назад +1

    How can I make the bullet stop colliding with another bullet or the player when moving forward? Basically, how can I make the bullet speed = some value + the player forward velocity? FYI, this isn't a layer issue currently, although I realise I need to look into this.
    EDIT: I created a bullet spawner that shifts forward based on the player's forward velocity to handle this edge case.

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

      chatgpt suggestion.. need insert above line Destroy(spawnedBullet...:
      // Ignore collision between the spawned bullet and all other bullets.
      foreach (GameObject otherBullet in GameObject.FindGameObjectsWithTag("Bullet"))
      {
      if (otherBullet != spawnedBullet)
      {
      Physics.IgnoreCollision(spawnedBullet.GetComponent(), otherBullet.GetComponent());
      }
      }
      // Ignore collision between the spawned bullet and the player.
      GameObject player = GameObject.FindGameObjectWithTag("Player");
      if (player != null)
      {
      Physics.IgnoreCollision(spawnedBullet.GetComponent(), player.GetComponent());
      }

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

      @@pastuh note that FindGameObjects is expensive so should not be used where a large amount of objects need to be referenced in a short amount of time, say for example when trying to reference a lot of bullets from a machiene gun. For the odd reference its ok but better to reference another way than find if you can

  • @Hobby_Technology
    @Hobby_Technology Год назад +1

    Fantastic tutorial! However, I am having one problem, when I try to move the attach point during runtime, nothing happens, so I need to guess and check when moving the attach point.

    • @skylarmuffin8145
      @skylarmuffin8145 Год назад +1

      I have this same problem?

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

      i'm having the same problem. have u found a solution for this?

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

      you can drop and pick up the item quickly while moving it in the inspector, this allows you to slowly move it bit by bit, but its kinda frustrating and slow. @@mansourzawad

    • @Vectif
      @Vectif 11 месяцев назад

      Having the same issue. Is there not a setting to allow it to edit in runtime?

  • @TheWestOwl
    @TheWestOwl Год назад +1

    Hey, I've been loving these videos and I found them really helpful. But there's one issue. When I made the "Fire Bullet On Activate" script it doesn't compile and when I restart the tab, it says "The associated script cannot compile" I also have an issue where the Attach Point on the gun doesn't move the actual gun. I have to guess and check but eventually I get a really good position where it fits in the right hand perfectly, but then the left hand is super off. Any fixes for either of the two??

  • @iminadoorgaming264
    @iminadoorgaming264 5 месяцев назад

    Is there a way that you can make it a different grab like a trigger grab?

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

    Hey @Valem Tutorials, is there a possible way I can make a line for the pistol so I know where it exactly shoots?

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

      Just add a LineRenderer as a child to your pistol ! Position it correctly, and set it to enabled and disabled just like we changed the color of the cube on Select Entered and Select Exited (at 4:22)

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

      @@Xarius, thank you so much!!!

  • @michellegabrielle2026
    @michellegabrielle2026 Год назад +1

    Maybe a silly question - but how are you managing to adjust the attach point transform so well while in game? In order to change the settings in Unity I have to let go of the controllers, take off the headset etc and it was not a smooth process at all

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

      i had same problem. you solved it?

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

      @@juanbrincadeira no, i ended up just copying his values from the video but i also want to know how to do it conveniently for future use

    • @PeterBickhofe
      @PeterBickhofe Год назад +2

      You can try to switch the "attach point compatibillty mode" to legacy for ajustments and then switch back to default. Guess its the newer toolkit version...

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

      @@PeterBickhofe Thanks for the tip, will try that!

  • @francopanigaia2425
    @francopanigaia2425 2 года назад +1

    Is it possible to teach us how to activate the teleportation only while the thumbstick is pushed forward, and make it disappear if the thumbstick is released? this way it's possible to control when the teleport is active and cancel the action. Text instructions will be more than enough. I tried this myself but I don't know how to use the Vector2 value to trigger activation. Thank you so much for everything you do.

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

      teleporter.SetActive((inputAction.action.ReadValue().y > 0.1F));
      This works for me using the Locomotion/Teleport Mode Activate action on the teleporter game object

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

      @@martwoods Thank you, sir! That .y after vector 2 is exactly what I needed! I had figured it out, but I hope this can help someone else.

  • @wanglinda2212
    @wanglinda2212 2 года назад +1

    Hello Valem! Great tutorial! Question:Why does my desk move back (keep away) when I grab for the cube ? 😂 Expecting a reply

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

      It doesn’t move away your just not moving forward because of the collision

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

      Change the size of your character controller component found within the XR origin so that you don't collide with the cube table. Make it slim, for instance radius, 0.1

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

      the cube is prob to far away, if you try to walk irl it wont let you

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

      He addressed this bug towards the end of the video. This is where he talked about setting the player and interactable layers. The cubes are causing a collision with your XR Origin, which in turn causes YOU to move backwards due to the physics interaction.

  • @Q21-x6v
    @Q21-x6v 8 месяцев назад

    Hello. That's a fantastic video! Is there a way to set the movement type to Velocity Tracking in the Meta XR All-in-One SDK?

  • @motobike5Dev
    @motobike5Dev 7 месяцев назад

    Your tutorial was excellent, but I'm having trouble with the grab function, in my scene i have an object to grab, so i grab it but i have a continuous rotation script on my right hand so whenever i rotate with that hand, the grabbed object doesn't rotate with the hand.

    • @motobike5Dev
      @motobike5Dev 7 месяцев назад

      Nevermind, i found the problem. Great video again.

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

    Hi :) I can't find the XR Grab Interactable script if I want to add the component. Up to this point everything went pretty well and I installed the XR Interaction Toolkit as learned in the previous videos. What did I wrong and how can I get the XR Grab Interactable script?

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

    Hi, after adding the interactors and interactables the game gives me an error that Direct interactor does not have required collider set as a trigger. I also noticed that on the direct interactor on the interaction manager tab, for me it said none and for you it said it had one.

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

      hi, the error might come from not checking "isTrigger". go to your hand object -> sphere collider -> check is Trigger

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

      @@yoOtzel Yup its this. I had the same problem, thanks for the help.

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

      @@Sssenstional i'm glad i could help ;)

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

    3:05 OUR OLD HANDS!
    We've come so far

  • @DavidRedmond-c7n
    @DavidRedmond-c7n Год назад +1

    Really love your video's so helpful and thorough. Can I ask with the script at the start for making the teleport ray disappear, I implemented everything and it works perfectly on one hand but not the other. hand , the trigger appears but does not cause the user to teleport. I have double checked and both hands are set up the same way I have also tried remaking the ray components and then it switched where the hand that was working the first time round was broken the second time and visa versa. Any thoughts or help greatly appreciated.

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

      Did you find a fix for this? I also have my rays working but the teleporting won't go off. If I disable this script, teleporting works fine

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

      Hey so I fixed by resetting the XR Controller component, make sure each interactor has it's own tied to the game object

  • @BetaFail
    @BetaFail Год назад +1

    (FIX): my collider was not in the correct position reletive to the hands, make sure your sphere collider in both the right and left hands are at 0,0,0
    Currently having a problem with the objects interacting with my custom made hands in blender, i keep getting to message "NullReferenceException: Object reference not set to an instance of an object", also im having problems with the teleportation ray/radical showing (i have the right hand unchecked but the left wont work), can anyway please help me.

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

      Idk if this helps, but i got the ray/radical working, and realized that it turned white when the ray was touching the cube, if i click trigger it turns yellow.

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

      holy shit, actual savior ty!

  • @Rohityoyo1997
    @Rohityoyo1997 7 месяцев назад

    When I try to throw the cubes away in the plane... the cube just somehow bypasses the plane and start falling. Can someone please help?

  • @LightYTB
    @LightYTB 6 месяцев назад

    idk why but when i use the joysticks when holding an object the object rotate and i can make the object float away how can i fix this ?

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

    For some reason I cant put my hands over my table, i've arranged the height f the table many times but my controllers cant reach the cube. Please help

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

    8:43 Anyone have a problem with attach point while in "game" ? My pistol doesnt move while I try to edit transform position/rotation values in game

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

      Yes, same here. I guess they changes comething in the newer toolkit version.

    • @PeterBickhofe
      @PeterBickhofe Год назад +1

      You can try to switch the "attach point compatibillty mode" to legacy for ajustments and then switch back to default.

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

      @@PeterBickhofe Thaanks

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

    how do I make realistic/physics based reloading?

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

      ruclips.net/video/IB-Jf7FdLGs/видео.html he made a tutorial for a pistol a year ago

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

      I made a tutorial going a bit further with the gun mechanism : ruclips.net/video/IB-Jf7FdLGs/видео.html
      this can help you i think

  • @MrDruw.
    @MrDruw. Год назад

    so when I try to grab the cube it doesn't do anything.

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

    help my xr interaction manager wont transfer to new things automatically and sometimes i cant click the bullseye looking thing and search for it. idk what to do

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

    Problemm :Direct Interactor does not have the required Collider as trigger.?????

  • @jonwon301
    @jonwon301 Год назад +1

    can someone help me i cant do the attach point part with the gun when i move the attach point hte gun dosent move????????????????

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

      Same for me, it only moves the attach point but the pistol is not moving, hence i have to let go and grab again the pistol so I can know if now the attach point is positioned correctly.
      Try letting go and grabbing again fast enough to see the change.

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

    Sorry for asking this but.. What do when pistol is invisible?

  • @Jacobb195
    @Jacobb195 Год назад +1

    when i finished the FireBulletOnActivate script nothing came up except for the script name, i have redone the script many times to no prevail

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

    When I set my grabbable objects onto a different layer, they disappear when I go into play mode 😮 I’m confused.

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

    When I put my hand next to the cube it wouldn’t change colors

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

    Minute 8.52 how do you do to move Attach to the hand using the glasses. I couldn't do that!

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

      Someone moved pistol attachpoint? i move it but it's not moving like the video.

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

      You can try to switch the "attach point compatibillty mode" to legacy for ajustments and then switch back to default. Guess its the newer toolkit version...

  • @wintxrpc
    @wintxrpc 11 месяцев назад

    Hey Valem! I am using your tutorials to create my VR Game. But for some reason the game is very laggy even with good settings a 1.5 GBPS link cable and a good pc it still lags with quest link! I have tried to use Virtual desktop but it doesn't open. What do you use to stream your game to your headset? I need to know!

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

    I have a problem. when I shoot the bullet goes to the left and not forward. How do I fix this?

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

    Great Videos!! Thanks Valem. One Question. Since I can set my glasses to not turn off, I can't find any options. It gets complicated every time I want to test something that has to turn on controllers and goggles.

  • @nexurolp5238
    @nexurolp5238 2 года назад +1

    Hi, great tutorial. I have one question, I made a sword model that I can grab, but while using velocity tracking it lags behind my hand. Anyone else encountered this problem? Thanks.

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

      @weHLDWNmiRWfxmvyKHzF Sorry not sure how you would fix this. I decided to go with Hurricane VR where this is solved.

    • @nexurolp5238
      @nexurolp5238 Год назад +1

      @weHLDWNmiRWfxmvyKHzF Oh 100%. It solves entire physics aspect quite well. If you would compare the time it would take you to create this system by yourself and paying $50 for the complete thing, it is definitely worth it

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

    What do you do if you want the gun to fire automatically like a rifle

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

    For some reason it only shoots when I grab it and won’t shoot unless I let go and grab it again and every time I press the thumb sticks it moves away from me can you help me please

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

    bro someone pls help me. i copied the code for the bullet and got this error: Assets\FireBulletOnActivate.cs(15,29): error CS1061: 'ActivateEvent' does not contain a definition for 'Addlistener' and no accessible extension method 'Addlistener' accepting a first argument of type 'ActivateEvent' could be found (are you missing a using directive or an assembly reference?)

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

    If someone wanted to use the trigger in order to grab certain objects, and the grip button to grab other objects, how might this be accomplished?
    Not me, asking for a friend, ofc.

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

    When holding objects and pressing thumbsticks in a direction the held item flies away

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

    Great video, it helped me a lot to get started in the world of VR development.
    I have just one question, is there any way to prevent the objects I grab from colliding with the player's collider without having to do it by code?
    I don't know, any option in XR Origin itself?

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

      Yes, layers. Its really simple :D

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

    hello any idea why my left controller uses select to grab the objects but my right controller is using the activate trigger, i can't find out where to change it and now i can really pick up the gun as the teleport always activates

  • @DayDreamSounds
    @DayDreamSounds Год назад +2

    Amazing tutorial series! However, I have become stuck on this one. When I walk around, the objects I am holding seem to move when I move. As in away from the player? Very odd

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

      I have the same problem. did you find a solution?

    • @That-Guy352
      @That-Guy352 Год назад +4

      Same I fly

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

      disable the kinetic animation mode i know it makes it work better with physics but as far as i know its the only way to fix it

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

      @@That-Guy352 do u flybackwards? i made a vid and put it on the forums for help but no one reponded yet. heres the vid. lemme know if its happening to u too. ruclips.net/video/lm8C4fkXCho/видео.html

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

      The XR Ray Interactor component, which is used on the hands, has a "Anchor Control" Checkbox. If you disable it, the grabbed object no longer moves if you use the thumbstick.

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

    Is there a way to change the input of my teleport reticle? The code in the video makes it so you teleport by holding down the main triggers and I would like to use X/A (oculus)

  • @SFG_Studios-f6u
    @SFG_Studios-f6u Год назад

    hi valem, im having an issue with my gun when i shoot, the bullets just spawn en dont go any where. could you help me pls.