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
@@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
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() {
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
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).
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!
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.
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.
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 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.
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."
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...
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.
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?
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?
@@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.
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
@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?
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
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.
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.
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 :)
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.
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...
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.
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
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.
@@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.
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.
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 ?
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
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); } }
@@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)
@@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”
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. 🧐
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.
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.
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.
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); } } }
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 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); } }
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.
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.
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.
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.
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()); }
@@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
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.
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
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??
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)
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
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...
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.
teleporter.SetActive((inputAction.action.ReadValue().y > 0.1F)); This works for me using the Locomotion/Teleport Mode Activate action on the teleporter game object
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
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.
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.
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?
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.
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.
(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.
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.
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
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.
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...
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!
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.
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.
@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
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
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?)
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.
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?
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
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
@@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
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.
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)
No cubes were harmed in the making of this video.
I am getting a namespace error
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
@@prso5587 Looks like this started off in English and slowly trailed off into French? :)
@@SgtMacKerZ yes because i think this guy is french like me x)
@@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
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);
}
}
thank you
it says the script cant be loaded because of compiling errors any ideas?
@@alexanderbirdie125 Are you sure the name of the script is the same as shown in the video?
THANKS!
OM, Thank you very much!
Loving this series, it's been an absolute god send for me
Loving this comment aswell
@@ValemTutorials Legend
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
I had the same problem, thanks man!
Could you explain this further please?
The left hand and right hand Sphere collider, turn of the is trigger?
omg thank you i spent about 1 hour
You're a genius
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).
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!
Thank you so much! I was wondering why I couldn't do that
Perfect!
Great series Valem! Thanks so much for this new course. :) Super cool you're sponsored by Unity!
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
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.
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.
Good remarks ! Better play it safe you're right
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.
wuuuuhhh new episode
Your videos are addictive ! Can't believe it's already ep.5
I did the script myself, Its so fun, I start to understand how things work
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
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.
Yes! I am having the same problem, have you found anything out??
@@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.
Excellent video for studying VR development! Everything was done. Thank you!
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."
Deleting the line indicators or whatever they're called seems to fix the issue.
@@Vs-ub4tqhow?
For those who have motion of character ,throwing character away while picking box,make sure you reduce your capsule collider radius
THANKS!
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...
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.
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?
Tal vez pudo resolver el problema? estoy con el mismo conflicto
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?
I have the same problem, did you ever fix it?
@@thenoseguy Sadly not, I've given up on my VR Project for now :(
@@skortle4529 I figured it out. Just gimme a sec to remember how I did it.
@@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.
make Shure there are no errors and that all of the code as a ; at the end of the line
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
put ur finger on the things that say 1 2 or 3 and it tricks it into thinking u ahve ur headset on
@@HalfTayem Thank you :)
Thanks Valem! These have been great tutorials.
@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?
so cool thanks mr Valem
Very informative thanks for this amazing video brother.
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
Hi henry thanks for watching the video, I'll take note on that idea it can be nice for a future tutorial thank you. :)
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
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.
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.
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 :)
Ah thank you ill defenitly take a look a the two hand tutorial!
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.
Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you...
Thank YOU SO MUCH BROOOOOOOOOO
Would you happen to know if there is a way to change how the hand grips around whatever object you are trying to grab?
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)
Great video, thanks so much. Would you say this updated Unity VR solution is better than the one in your older video?
i love this im actually making a vr game thanks for the help man
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...
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.
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
might be late but for me my fix was decreasing the size of the radius on the character controller.
I can't fire the bullet...i have problem with script
Great tutorial, helps a lot.
timing 10:13 not working with meta All-in-one last lib..
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
Same here
is there a way to change the trigger/button that you have to use for the grabbing system? Love your tutorials :D
12:20 the options under the fire bullet on activate aren’t showing up for me. How do fix this?
Why when I put an object that I take with my hand, does it lift or move me?
Whenever I grab the cube, I get launched a thousand miles into the air. Has anyone else ran into that issue?
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.
@@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.
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.
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 ?
Hey, could you teach us how to code a sword like in Blade and Sorcery?
Would be nice :) chop some trees in jungle
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
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);
}
}
Thank you boss
You are the best, I thought I was going crazy it wasn't working for me
@@reflexclutch1571 did you succeed with the bullet script ?
ty
@@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)
can you make a tutorial on how to make the force in unity like in the oculus game Vader Immortal?
Interesting topic I'll look into it :) thanks for watching
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.
Yes! have you found anything?? I cant find anything
@@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”
@@cloudd_08 where do i find that
how do i get the XR Interaction Manager?
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. 🧐
super helpful tutorial. do you plan on making a video on how to make the player jump?
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.
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
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.
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.
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);
}
}
}
@@blackmagegamestudio oh I already got this working, thank you though!
@@StatusTechDev I figured since the post was a month old... BUT... dropped the comment in case someone else has the same question!
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?
If you get a reply let me know.
@@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);
}
}
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.
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.
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.
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.
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());
}
@@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
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.
I have this same problem?
i'm having the same problem. have u found a solution for this?
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
Having the same issue. Is there not a setting to allow it to edit in runtime?
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??
Is there a way that you can make it a different grab like a trigger grab?
Hey @Valem Tutorials, is there a possible way I can make a line for the pistol so I know where it exactly shoots?
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)
@@Xarius, thank you so much!!!
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
i had same problem. you solved it?
@@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
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...
@@PeterBickhofe Thanks for the tip, will try that!
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.
teleporter.SetActive((inputAction.action.ReadValue().y > 0.1F));
This works for me using the Locomotion/Teleport Mode Activate action on the teleporter game object
@@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.
Hello Valem! Great tutorial! Question:Why does my desk move back (keep away) when I grab for the cube ? 😂 Expecting a reply
It doesn’t move away your just not moving forward because of the collision
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
the cube is prob to far away, if you try to walk irl it wont let you
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.
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?
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.
Nevermind, i found the problem. Great video again.
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?
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.
hi, the error might come from not checking "isTrigger". go to your hand object -> sphere collider -> check is Trigger
@@yoOtzel Yup its this. I had the same problem, thanks for the help.
@@Sssenstional i'm glad i could help ;)
3:05 OUR OLD HANDS!
We've come so far
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.
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
Hey so I fixed by resetting the XR Controller component, make sure each interactor has it's own tied to the game object
(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.
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.
holy shit, actual savior ty!
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?
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 ?
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
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
Yes, same here. I guess they changes comething in the newer toolkit version.
You can try to switch the "attach point compatibillty mode" to legacy for ajustments and then switch back to default.
@@PeterBickhofe Thaanks
how do I make realistic/physics based reloading?
ruclips.net/video/IB-Jf7FdLGs/видео.html he made a tutorial for a pistol a year ago
I made a tutorial going a bit further with the gun mechanism : ruclips.net/video/IB-Jf7FdLGs/видео.html
this can help you i think
so when I try to grab the cube it doesn't do anything.
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
Problemm :Direct Interactor does not have the required Collider as trigger.?????
can someone help me i cant do the attach point part with the gun when i move the attach point hte gun dosent move????????????????
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.
Sorry for asking this but.. What do when pistol is invisible?
when i finished the FireBulletOnActivate script nothing came up except for the script name, i have redone the script many times to no prevail
this is also happening to me have you found a fix
same
When I set my grabbable objects onto a different layer, they disappear when I go into play mode 😮 I’m confused.
When I put my hand next to the cube it wouldn’t change colors
Minute 8.52 how do you do to move Attach to the hand using the glasses. I couldn't do that!
Someone moved pistol attachpoint? i move it but it's not moving like the video.
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...
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!
I have a problem. when I shoot the bullet goes to the left and not forward. How do I fix this?
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.
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.
@weHLDWNmiRWfxmvyKHzF Sorry not sure how you would fix this. I decided to go with Hurricane VR where this is solved.
@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
What do you do if you want the gun to fire automatically like a rifle
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
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?)
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.
When holding objects and pressing thumbsticks in a direction the held item flies away
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?
Yes, layers. Its really simple :D
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
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
I have the same problem. did you find a solution?
Same I fly
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
@@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
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.
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)
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.