Great video. I'm following you now. You do an amazing job. The code download link is dead though. Also, your picture during the coding obscures some of the code you write. This is really a problem when you're typing literal strings (as in the case of the action maps). Thanks!
Best part of the video was admitting you couldn't figure out the rotation. Your video is helping me a lot with my project and seeing someone humble about learning and their knowledge is awesome.
Hey, your channel just got recommended for me and I have to say that I'm only 10 minutes in and I'm really impressed! I can see you put a lot of work and effort into these videos and I know that if you'll keep uploading that often your channel will be very known. I like the camera and the lights behind it and it's really given me a studio and professional feeling. Right now I don't have a VR headset but I'm planning on buying one soon. Keep up the great work man, I appreciate your effort, Matan.
For anyone who wants to make the function working on the right hand instead., here are the steps: 1. In the script, change the "XRI LeftHand" to "XRI RightHand" 2. [Important] Make sure the XRI RightHand's "Move" action is not empty, if there is no action relates to it, click on the + button and choose "Add binding". In the path, choose "Primay2DAxis [RightHand Controller]". (By default, there is no move action in the Right Hand controller, if you don't add the Move action, the `_thumbstick.trigger` is always falsy, and as a result, the teleport beam will stay active and cannot be cancelled by releasing thumbstick.) 3. Drag the right hand raycaster to the script
Hello Justin! Your video is amazing and easy to understand! Here are my tips: First,the XR interaction tookit has updated and the action map has changed; The input actions like “Teleport Mode Activate” and "Teleport Mode Cancel" have been moved to the XRI LeftHand Locomotion. Secondly, I found the teleportion does not go as well as I expected : When I release the thumbstick , I found myself teleported to somewhere else instead of the XR ray hit point. Finally ,I found that the rayInteractor.enabled and _isActive should be set false after the method QueueTeleportRequest being excuted.If you don't do that, the teleportation method may be excuted many times during the time the thumstick returning back to the origin. Thanks a lot!
Just a question if i try to teleport outside of the plane i get a red ray and the code prevent me to do it just like u show it in the video. But if we add a cube or bowling alley ;) over the plane and don't add a teleportation area to it. Even if i get a red ray when i pass over it when i realease the thumbstick it will teleport me on that area anyway any clue why ???
Oh I think I forgot to add a check on the hit.gameobject for a teleportation area! You’ll need to add that and determine if you can teleport on not using that. Good catch!
@@JustinPBarnett Thanks for the advice i have modify the test in the update for : if (!_rayInteractor.GetCurrentRaycastHit(out RaycastHit hit) || hit.transform.GetComponent() == null) { _rayInteractor.enabled = false; _isActive = false; return; } and now it work. I can't teleport on a non teleportable area. Non sure it's the best way to do it but it worked :)
Random guess, but to get the rotation for the teleport couldn't you disable the snap turning while the teleport is active, and use the right hand to handle your teleport rotation?
@@JustinPBarnett Hmmm, Does your thumbstick have a "Middle click" so instead of teleporting on releasing the stick you could teleport on clicking it, and track the rotation before clicking. Or like enter tp mode by moving the stick, use the stick to rotate and then pull the trigger to finalize the tp.
@@xZeroCCx There is a game called Fuji on the quest, they set up the controls so you can teleport with both sticks, but if you are teleporting with one and try to start to teleport with the other it just cancels the current teleport.
I actually think it is more natural to have the teleport on release of the sticks. Pretty much the majority of the VR games have it implemented like this, so thats what people will expect.
Hi, i do this tutorial. But my Unity editor not response to oculus controller click... you know any solution? Unity can track the controls movement but for example i cant teleport with buttons in my unity editor.
Hey Justin. Any recommendation for if we'd like to track the number of times a user has teleported using the Locomotion System? I tried adding code to the base Teleportation Provider, but that ended up being immutable and reverting. If I wanted to create a TeleportationManager script like you did, how would I determine when my new "teleportationCount" variable would need to be incremented? (i.e. how could I track when the XR Origin was successfully teleported.) Thanks in advance!
Awesome tutorial! This is really helping with my coursework for my Uni. However, I've encountered a problem where the error code is the following: NullReferenceException: Object reference not set to an instance of an object TeleportationManager.Start() (at Assets/TeleportationManager.cs.20) I've checked the code on line 20 and it seems that it was this line "var activate = actionAsset.FindActionMap("XRI LeftHand").FindAction("Teleport Mode Activate");" that Unity wasn't liking. Been trying to solve this for over an hour by going through the tutorial and still no results. Any advice?
@@JustinPBarnett If you are talking about the names for the action e.g. InputActionAsset actionAsset, then yes! Somehow the error didn't show up anymore but have encountered another problem, where the teleportation ray doesn't appear at all when I try to pull the thumbstick towards me or the opposite direction. Perhaps it might be easier if I just post a screenshot of the code that I've copied from yours and see if there is any error... Sorry for the inconvenience! i.imgur.com/YC11vSB.png
@@BonCreations I’m starting to think that you didn’t set something in the inspector. Like for got to attach the action asset in its slot in the teleportation manager. Your code looks fine as far as I can tell
@@JustinPBarnett I also have completed that step by dragging the XRI Default Input Actions to the slot. Thought it would be worth mentioning, is that I have also followed the continuous movement tutorial that you have uploaded before and I tried to combine both of them together. I was wondering if the continuous movement tutorial that I also followed and applied to the same XR Rig before might be the reason for the error?
Hi Justin! Thanks for the tutorial, that really helped me along. One thing that didn't work out for me was that my teleportation happened pretty much instantaneously. The 'thumbStick.triggered == true' did not behave as expected. To fix this, I first created a new action for the Primary2DAxis, which I set to 'Value' and 'Vector2' as the Control Type. I then referenced that action instead of the Move action in the code, and used 'if (thumbStick.ReadValue() != Vector2.zero) { return; }'. This worked for me, I hope someone else finds it useful too.
Thank you very much for this. I could not figure it out the for the life of me. Another thing I did was got rid of the isActive boolean. Since we are already toggling rayInteractor enabled/disabled, just check that boolean to simplify the code a bit.
Thanks! I spent 1h trying to find why my thumbstick wasn't staying on triggered state (had the problem only in build, not in editor) and your solution worked for me ;)
Same thing here - thank you for this excellent solution. I didn't even need to set up a new input action, I just left the reference to the existing Move action and used your code in the update loop and it sorted the issue for me.
Hi Justin, how would you create teleportation area on complicated meshes, such as it is in walkabout mini golf or Star Wars Tales from the Galaxy Edge?
Thank you for the cool video! I came here to see if I could figure out how to add a cool-down to the teleportation because I would like the user to take in the environment before moving on too quickly but I couldn't quite figure it out. Should I use some sort of timer in combination with the provider.QueueTeleportRequest() for this or do you have any other idea?
Nice tutorial, and demonstrates the logic by linking input to action. Quick question- why wouldn't you use a Player Input component to isolate the control action and use it to broadcast to your methods in the Teleportation Manager? That removes the need to hard-code a controller input and gives more flexibility further down the line (which is what the new Input System aims to do).
Yea I'm sure it's entirely possible to do with a FPS or 3PS style game. Not sure what you mean by save as a phone or website though? Can you elaborate?
Here's the solution I found for the Rotation problem you ran into: I use a game object as the "Reticle" for the XR Ray Interactor > XR Interactor Line Visuals. I then use the joystick input, find the direction based on the Vector2 and the Transform of the controller being used > ```Vector3 joystickDirection = controllerTransform.right * joystickRotationValue.x + controllerTransform.forward * joystickRotationValue.y;``` after this, you want to 0 out the Y coordinate of of joystickDirection.y to keep the reticle flat against the ground. ```joystickDirection.y = 0``` I also normalized the joystickDirection, but I don't think it's necessary I then use that to rotate the Reticle > ```Quaternion newRotation = Quaternion.LookRotation(forwardDirection, Vector3.up); reticleTransform.rotation = Quaternion.RotateTowards(reticleTransform.rotation, newRotation, 10000 * Time.deltaTime);``` Then in the Teleport Request > ```destinationRotation = new Quaternion(0, Mathf.Round(reticleTransform.rotation.y), 0, 0), matchOrientation = MatchOrientation.TargetUpAndForward``` Essentially, serializing the rotation of the joystick inside the Tranform of the reticle and applying that during the teleport request. I'm currently running this under the Update method, but only if my teleporter is currently active. I'm looking to find a way to get this out of Update() so it's not checking for an if statement every frame.
@@JustinPBarnett Thanks for the fast reply (and the Tutorial) :) Unfortunately I do not have any programming knowledge and do not know how to do this. I tried to copy part of the code from your VR Hands tutorial and I can't get it to work. So I will just accept that and will only grab with the right hand :D
Great video! I'm still having one issue I can't quite solve. Mine seems to teleport immediately even while the joystick is stick being held. Any thoughts on where to look for that? I've double and triple checked the code, but can't track it down.
@@JustinPBarnett Sounds like you're talking about C# code. I've double and triple checked it. Even compared it to some code I found in a post below. The only differences were expected. I'm lost. Here's the bit of code I believe you're referring to. If you're talking about something else, I can't find it. void Update() { if (!_isActive) return; if (_thumbstick.triggered) return; if (!rayInteractor.TryGetCurrent3DRaycastHit(out RaycastHit hit)) {
@@JustinPBarnett One last thing occurred to me. I recently followed a different tutorial. Setup a sphere. I could grab it with the left or the right controller. Worked perfectly. I could hold it with my left controller and grab it with my right controller. But, I couldn't hold it with the right and grab it with the left. I watched the video 2-3 times, spent hours trying to figure it out and finally gave up. Now this issue. Might there be something else going on here? Could it be at this point in time it's just a pre-release bug with XR Interaction Toolkit? That's two unexplainable (to me) bugs with the left controller now.
Thanks for these tutorials. I'm able to get the raycast to come out and the grip to deactivate it but releasing the thumbstick doesn't do anything - the ray just remains cast and it doesn't teleport. The only difference I'm able to see in the script is that Unity made me update GetCurrentRaycastHit to TryGetCurrent3DRaycastHit. Any thoughts on what I might be missing?
As far as I've been able to tell, GetCurrentRayCastHit still works. Though I am trying to figure out a Flicking issue with my Ray. Are you sending the TeleportQueueRequest? Just switch over to TryGetCurrent3DRaycastHit and it seems to be working out for me.
@@Breyyne I made the switch to TryGetCurrent3DRaycastHit. I am sending the request. My Update function looks like this: void Update() { if (!_isActive) return; if (_thumbstick.triggered) return; if (!rayInteractor.TryGetCurrent3DRaycastHit(out RaycastHit hit)) { rayInteractor.enabled = false; _isActive = false; return; } TeleportRequest request = new TeleportRequest() { destinationPosition = hit.point, //destinationRotation = , }; provider.QueueTeleportRequest(request); rayInteractor.enabled = false; _isActive = false; }
@@Breyyne Turns out it is working but not as expected. When I press the stick forward, the ray comes out but doesn't teleport me. If I hold the grip down and then push the stick forward, the ray comes out and teleports me.
Hello Justin, Thank you for this amazing tutorial! One question though, because I am a complete beginner to coding: in visual studio 2019, although the predictions work, the visuals are different to your in the tutorial. is there some integration settings that I have to implement in my options?
Try creating an empty game object as a child of each controller and rotate that to where you like it. Then you can move the ray interactor and line renderer component to the child object and that should work.
Thanks for the tutorial. I have a question that if I use the Teleportation Manager script in the video, I can teleport to the area which does not have "Teleportation Area" script. However, my expectation is to teleport only on teleport areas, so could you give any suggestions to solve this problem?
Hi Justin, Thank you for the great tutorial. This have an small issue, When you try this on a plane without "Teleportation Area" Script attached, instead include teleportation anchors, movement is bit weird and it does teleport within that plane without the "Teleportation Area" script. Also this does cause positioning issues when we teleport into anchors. Can you suggest solution to fix this? Thank you in advance!
Teleporting onto anchors will move the player to that exact spot. It's different than a teleportation area. If you're still having issues join the Discord and we can help you troubleshoot in #dev-help!
hello, I have a small problem involving teleportation. I'm instantiating the player in the scene because the phase is a multiplayer one, however the "teleportation area" script that is on the ground for the use of the teleport only recognizes the "teleportation provider" script of the player if he is already in the scene when the player comes. how to solve it? I already tried dragging and dropping the script directly from the prefab to be instantiated but it didn't work...
You could set the references inside the start method of the Teleportation Manager that was created here. This is just an example for one teleport object, if you have multiple areas or anchors you need to do some kind of loop. void Start() { var teleportArea = FindObjectOfType(); teleportArea.teleportationProvider = GetComponent(); // here comes the other code from this tutorial }
This method works fine with Quest2 joystick or controllers with a joystick but is there a way to make this work with HTC Vive Wand Controller cause the Keypad auto teleport on pointing even if i dont release it. I can't find the way to put this on the KeyPad Press instead of Touch
You'll need to go into the Input Actions and find the HTC Vive Wand controller option and pick the specific input you want to use from that. So around 8:30 instead of using those action maps you can create your own specific one to use and map to.
@@JustinPBarnett But is it possible to make both controllers work in same app ? Like is it possible in script to detect which system i am using and call the actions according to the headset ?
I don't see the problem about setting the rotation about the thumbstick position, just save the thumbstick vector2 when it' is greater that 0.9f for example, and calculate the rotation with that
Thanks for the great tutorial. I have a weird behaviour on my project. the teleportation is a bit far than expected although the teleportation area is not that wide. do you know what might be the reason for that?
Hi Justin! I want to be teleported with the XR Interaction Toolkit using a button. (where ı want) It doesn't happen when I call TeleportAnchor for the button. How can I do it?
Hello Justin! I am currenty using your tutorials for my bachelor's degree and I have a problem with this part. I followed your tutorial to animate hands beforehand and after doing this tutorial my rays do not cast anymore and I cannot teleport. Is there any solution for this, or did I mess up something? I am also seeing that my Line Renderer associated to my controller automatically disables itself when I enter play mode. Thanks in advance!
ich like your stuff a lot...thx!! one suggestion: your cuts are often very fast, so that i can almost not follow what you are doing.. a little little bit slower might be better :)
HI, Great tutorial. Everything works fine in unity itself, but when i build it to android device (quest2) it doesn't work correctly. When i'm pushing the thumbstick forward it teleports right away, without releasing the thumbstick. Any idea what the problem is?
@@JustinPBarnett Thanks for the reply & good question! It might have something to do with the models I downloaded (temp models) for the scene. When I use a basic sphere I can grab via the ray, ideal case I could grab with the hands from previous tutorial. I'll have to try it with the real models once I get them.
Hi Justin, i was trying to setup the teleportation and i am using a plane because i made a room in probuilder and inverted the uvs of a cube to make it so i can't use it for the teleportation zone. when i press the trigger to move and then release to choose where i want to teleport i shoot across the room and im unable to get to a specific location like in the middle of the room can you try help? thanks!
I found this comment below "This teleportation method has nice behaviour in the editor, but in the android build, teleportation happens immediately when I press the joystick" Anyone found the solution? Thanks! Your videos are amazing, help me a lot!!
Looking forward to your updated video. Followed the this tutorial and manipulated it to my liking. But the right hand controller is still active too! It teleports on grip release, which is super annoying because I'm using the right controller to interact with grabbables. If I don't point at a grabbable I get teleported. In the XRI RightHand Locomotion action map I removed all the Bindings from the Actions (Teleport Select, Teleport Mode Activate and Teleport Cancel) in the XRI Default Input Actions...
I inadvertently updated the XR Interaction Toolkit to the latest version (2.0.1). Typical newbie mistake. Ignored the warning that it was going to break the project. I could have used Collab to go back to the original version, but thought it might be interesting to fix the breaks that happened. The XRI Default Input Actions are very different. It broke the navigation on the left hand totally, although the right turn was still working nicely. Still testing a few more changes. I'll try to post them here and on the Discord. Has anyone tried this 2.0.1 version yet?
I ran into the same issue. The ActionMap has changed with the update. Use these instead in the c# script: var activate = actionAsset.FindActionMap("XRI LeftHand Locomotion").FindAction("Teleport Mode Activate"); var cancel = actionAsset.FindActionMap("XRI LeftHand Locomotion").FindAction("Teleport Mode Cancel"); _thumbstick = actionAsset.FindActionMap("XRI LeftHand Locomotion").FindAction("Move");
Hi Justin, thanks for the tutorial. Do you plan on making an updated tutorial for Unity 2021, It looks like some of the API's have changed and this no longer works :( also in future videos showing the full line of code and going a bit slower when creating the variables/autofilling would really help out a lot.
I really liked the tutorial it was easy to follow and easy to implement. Not sure if anyone proposed a solution but I did manage to get the facing issue resolved. Not sure if it's the best solution but it does work. I created a standalone GameObject to use as a recticle. I gave the object an obvious "front", enable, and place it at the hit point whenever the rayInteractor "isActive". There's a little math to convert the 2d axis into a rotation angle Vector2 directionVec = thumbStickAction.ReadValue(); float angle = Mathf.Atan2(directionVec.y, directionVec.x) * Mathf.Rad2Deg; landingReticle.transform.rotation = Quaternion.Euler(new Vector3(0, -angle, 0)); // This is assuming you're rotating around the Y axis. Some minor adjustments to align the objects "forward" with the angle you have to add 2 lines to the teleportRequest code. teleportRequest.matchOrientation = MatchOrientation.TargetUpAndForward; //
@@JustinPBarnett It would be great if you could add to the update how to change the length of the teleport arc based on the amount the thumb stick is pressed Although it would likely then need to activate with trigger rather than release.
Hi Justin, I've solved the issue you have with the teleportation rotation in the video. But I'm not fully sure how to send you an email or message. Please let me know how to followup or I can explain in the comments.
In regards to directional teleporting, you might find an answer by seeing how Oculus implemented it in their Unity integration. This tutorial implements what you're describing: ua-cam.com/video/r1kF0PhwQ8E/v-deo.html
I should mention that while mathematically the magnitude of the thumbstick pressing against the socket is equal to 1, in practice the number might be smaller (0.99 for example). The same goes for the center being point (0,0). You may want to use inequalities in the if statements to allow for a deadzone and a tolerance for the thumbstick.
@@JustinPBarnett I still can,t get the teleport to work with controller on new input system I tried changing the code when I turn off teleport controller it works but I want to turn off by button
Amazing video, I had the same problem as some people that the trigger wasnt working correctly, changed to: if (_thumbstick.ReadValue() != Vector2.zero) return; And it worked just fine. Another problem was the teleport was going too far away but I figured that the teleportation was being activated more than once so after I do the TeleportRequest I just added this two lines: provider.QueueTeleportRequest(request); rayInteractor.enabled = false; _isActive = false; Hope this helps someone :)
Download the Project (for FREE): www.vrcreators.io/codedownloads
Great video. I'm following you now. You do an amazing job. The code download link is dead though. Also, your picture during the coding obscures some of the code you write. This is really a problem when you're typing literal strings (as in the case of the action maps). Thanks!
Best part of the video was admitting you couldn't figure out the rotation. Your video is helping me a lot with my project and seeing someone humble about learning and their knowledge is awesome.
Hey, your channel just got recommended for me and I have to say that I'm only 10 minutes in and I'm really impressed!
I can see you put a lot of work and effort into these videos and I know that if you'll keep uploading that often your channel will be very known.
I like the camera and the lights behind it and it's really given me a studio and professional feeling.
Right now I don't have a VR headset but I'm planning on buying one soon.
Keep up the great work man, I appreciate your effort,
Matan.
Wow, I really appreciate all the praise and encouragement Matan! Thanks so much! (And getting a VR headset is SO fun!)
Your channel is very cool man I didn't know anything about vr but when I found your channel my life changed❤
Welcome aboard!
For anyone who wants to make the function working on the right hand instead., here are the steps:
1. In the script, change the "XRI LeftHand" to "XRI RightHand"
2. [Important] Make sure the XRI RightHand's "Move" action is not empty, if there is no action relates to it, click on the + button and choose "Add binding". In the path, choose "Primay2DAxis [RightHand Controller]".
(By default, there is no move action in the Right Hand controller, if you don't add the Move action, the `_thumbstick.trigger` is always falsy, and as a result, the teleport beam will stay active and cannot be cancelled by releasing thumbstick.)
3. Drag the right hand raycaster to the script
Thanks!
You can find an example on discord in vr-resources
Hello Justin! Your video is amazing and easy to understand!
Here are my tips:
First,the XR interaction tookit has updated and the action map has changed;
The input actions like “Teleport Mode Activate” and "Teleport Mode Cancel" have been moved to the XRI LeftHand Locomotion.
Secondly, I found the teleportion does not go as well as I expected : When I release the thumbstick , I found myself teleported to somewhere else instead of the XR ray hit point.
Finally ,I found that the rayInteractor.enabled and _isActive should be set false after the method QueueTeleportRequest being excuted.If you don't do that, the teleportation method may be excuted many times during the time the thumstick returning back to the origin.
Thanks a lot!
Thanks a lot, I was on this issue for like 2hours, you save me !
Just a question if i try to teleport outside of the plane i get a red ray and the code prevent me to do it just like u show it in the video. But if we add a cube or bowling alley ;) over the plane and don't add a teleportation area to it. Even if i get a red ray when i pass over it when i realease the thumbstick it will teleport me on that area anyway any clue why ???
Oh I think I forgot to add a check on the hit.gameobject for a teleportation area! You’ll need to add that and determine if you can teleport on not using that. Good catch!
@@JustinPBarnett Thanks for the advice i have modify the test in the update for :
if (!_rayInteractor.GetCurrentRaycastHit(out RaycastHit hit) || hit.transform.GetComponent() == null)
{
_rayInteractor.enabled = false;
_isActive = false;
return;
}
and now it work. I can't teleport on a non teleportable area. Non sure it's the best way to do it but it worked :)
@@lacoors Yup! good catch & solution
these vr tutorials are very cool I have to say. I am making a spiderman game, imagine how sick that would b in VR
That would be incredible!!
You should try out vrinteraction framework by Bearded Ninja
Random guess, but to get the rotation for the teleport couldn't you disable the snap turning while the teleport is active, and use the right hand to handle your teleport rotation?
That's a possibility, but I'd love to be able to use the same stick I'm using to teleport to also set the rotation.
@@JustinPBarnett Hmmm, Does your thumbstick have a "Middle click" so instead of teleporting on releasing the stick you could teleport on clicking it, and track the rotation before clicking.
Or like enter tp mode by moving the stick, use the stick to rotate and then pull the trigger to finalize the tp.
Firing the TP on stick release works, but unless you find an invalid target there isn't a way to cancel our teleport right?
@@xZeroCCx There is a game called Fuji on the quest, they set up the controls so you can teleport with both sticks, but if you are teleporting with one and try to start to teleport with the other it just cancels the current teleport.
I actually think it is more natural to have the teleport on release of the sticks. Pretty much the majority of the VR games have it implemented like this, so thats what people will expect.
Hi, i do this tutorial. But my Unity editor not response to oculus controller click... you know any solution? Unity can track the controls movement but for example i cant teleport with buttons in my unity editor.
Join the discord and we can help you troubleshoot!
Hey Justin. Any recommendation for if we'd like to track the number of times a user has teleported using the Locomotion System? I tried adding code to the base Teleportation Provider, but that ended up being immutable and reverting. If I wanted to create a TeleportationManager script like you did, how would I determine when my new "teleportationCount" variable would need to be incremented? (i.e. how could I track when the XR Origin was successfully teleported.) Thanks in advance!
You'd have to override the teleport method and add a counter to it
Awesome tutorial! This is really helping with my coursework for my Uni. However, I've encountered a problem where the error code is the following:
NullReferenceException: Object reference not set to an instance of an object
TeleportationManager.Start() (at Assets/TeleportationManager.cs.20)
I've checked the code on line 20 and it seems that it was this line "var activate = actionAsset.FindActionMap("XRI LeftHand").FindAction("Teleport Mode Activate");" that Unity wasn't liking. Been trying to solve this for over an hour by going through the tutorial and still no results. Any advice?
Do you have an action of that name set up?
@@JustinPBarnett If you are talking about the names for the action e.g. InputActionAsset actionAsset, then yes!
Somehow the error didn't show up anymore but have encountered another problem, where the teleportation ray doesn't appear at all when I try to pull the thumbstick towards me or the opposite direction. Perhaps it might be easier if I just post a screenshot of the code that I've copied from yours and see if there is any error... Sorry for the inconvenience!
i.imgur.com/YC11vSB.png
@@BonCreations I’m starting to think that you didn’t set something in the inspector. Like for got to attach the action asset in its slot in the teleportation manager. Your code looks fine as far as I can tell
@@JustinPBarnett I also have completed that step by dragging the XRI Default Input Actions to the slot. Thought it would be worth mentioning, is that I have also followed the continuous movement tutorial that you have uploaded before and I tried to combine both of them together.
I was wondering if the continuous movement tutorial that I also followed and applied to the same XR Rig before might be the reason for the error?
@@BonCreations hmmm so you’re trying to use continuous movement and teleportation at the same time?
Great videos, sending my support, keep doing what yr doing yr great!
Thank you so much!!
Hi Justin! Thanks for the tutorial, that really helped me along. One thing that didn't work out for me was that my teleportation happened pretty much instantaneously. The 'thumbStick.triggered == true' did not behave as expected. To fix this, I first created a new action for the Primary2DAxis, which I set to 'Value' and 'Vector2' as the Control Type. I then referenced that action instead of the Move action in the code, and used 'if (thumbStick.ReadValue() != Vector2.zero) { return; }'. This worked for me, I hope someone else finds it useful too.
Glad you got it working!
Thank you very much for this. I could not figure it out the for the life of me. Another thing I did was got rid of the isActive boolean. Since we are already toggling rayInteractor enabled/disabled, just check that boolean to simplify the code a bit.
Thanks! I spent 1h trying to find why my thumbstick wasn't staying on triggered state (had the problem only in build, not in editor) and your solution worked for me ;)
OHHHHHHHHHHHHHHHHHHHHHHHHHHH IT WORKS PREFECTLY!
Same thing here - thank you for this excellent solution. I didn't even need to set up a new input action, I just left the reference to the existing Move action and used your code in the update loop and it sorted the issue for me.
Hi Justin, how would you create teleportation area on complicated meshes, such as it is in walkabout mini golf or Star Wars Tales from the Galaxy Edge?
Just add a teleportation area to the mesh!
Thank you for the cool video!
I came here to see if I could figure out how to add a cool-down to the teleportation because I would like the user to take in the environment before moving on too quickly but I couldn't quite figure it out. Should I use some sort of timer in combination with the provider.QueueTeleportRequest() for this or do you have any other idea?
Nice tutorial, and demonstrates the logic by linking input to action. Quick question- why wouldn't you use a Player Input component to isolate the control action and use it to broadcast to your methods in the Teleportation Manager? That removes the need to hard-code a controller input and gives more flexibility further down the line (which is what the new Input System aims to do).
That's actually a really great suggestion! Should work pretty good
@@JustinPBarnett Yep- works an absolute treat! Will write it up when I get 5 minutes...
can you teleport without the VR Headset and just mouse-click around? Also, how can I save this as a phone or website for people to access?
Yea I'm sure it's entirely possible to do with a FPS or 3PS style game. Not sure what you mean by save as a phone or website though? Can you elaborate?
@@JustinPBarnett means, how we can test this VR Game in Mobile that you are testing in game panel in unity.
Also do we need VR Headset to teleport it?
Here's the solution I found for the Rotation problem you ran into:
I use a game object as the "Reticle" for the XR Ray Interactor > XR Interactor Line Visuals.
I then use the joystick input, find the direction based on the Vector2 and the Transform of the controller being used >
```Vector3 joystickDirection = controllerTransform.right * joystickRotationValue.x + controllerTransform.forward * joystickRotationValue.y;```
after this, you want to 0 out the Y coordinate of of joystickDirection.y to keep the reticle flat against the ground.
```joystickDirection.y = 0```
I also normalized the joystickDirection, but I don't think it's necessary
I then use that to rotate the Reticle >
```Quaternion newRotation = Quaternion.LookRotation(forwardDirection, Vector3.up);
reticleTransform.rotation = Quaternion.RotateTowards(reticleTransform.rotation, newRotation, 10000 * Time.deltaTime);```
Then in the Teleport Request >
```destinationRotation = new Quaternion(0, Mathf.Round(reticleTransform.rotation.y), 0, 0),
matchOrientation = MatchOrientation.TargetUpAndForward```
Essentially, serializing the rotation of the joystick inside the Tranform of the reticle and applying that during the teleport request.
I'm currently running this under the Update method, but only if my teleporter is currently active. I'm looking to find a way to get this out of Update() so it's not checking for an if statement every frame.
Why did you leave Teleport Mode Cancel set to "gripPressed"?
I'm going to do an update video on teleporting soon. Not super happy with the solution in this video and I feel like there's a better way to do it.
Am I missing something or how am I able to use the left hand to teleport and be able to grab objects at the same time?
Should be the same ray interactor, you'd just need to leave it on all the time (or make it visible when hovering over an interactable object)
@@JustinPBarnett Thanks for the fast reply (and the Tutorial) :) Unfortunately I do not have any programming knowledge and do not know how to do this. I tried to copy part of the code from your VR Hands tutorial and I can't get it to work. So I will just accept that and will only grab with the right hand :D
Great video! I'm still having one issue I can't quite solve. Mine seems to teleport immediately even while the joystick is stick being held. Any thoughts on where to look for that? I've double and triple checked the code, but can't track it down.
Sounds like you're running the teleport action on stick pushed instead of stick released and put back to 0
@@JustinPBarnett Sounds like you're talking about C# code. I've double and triple checked it. Even compared it to some code I found in a post below. The only differences were expected. I'm lost. Here's the bit of code I believe you're referring to. If you're talking about something else, I can't find it.
void Update()
{
if (!_isActive)
return;
if (_thumbstick.triggered)
return;
if (!rayInteractor.TryGetCurrent3DRaycastHit(out RaycastHit hit))
{
the _thumbstick variable is defined as: private InputAction _thumbstick;
The _thumbstick variable is set here:
_thumbstick = actionAsset.FindActionMap("XRI LeftHand").FindAction("Move");
_thumbstick.Enable();
@@JustinPBarnett One last thing occurred to me. I recently followed a different tutorial. Setup a sphere. I could grab it with the left or the right controller. Worked perfectly. I could hold it with my left controller and grab it with my right controller. But, I couldn't hold it with the right and grab it with the left. I watched the video 2-3 times, spent hours trying to figure it out and finally gave up.
Now this issue. Might there be something else going on here? Could it be at this point in time it's just a pre-release bug with XR Interaction Toolkit? That's two unexplainable (to me) bugs with the left controller now.
Thanks for these tutorials. I'm able to get the raycast to come out and the grip to deactivate it but releasing the thumbstick doesn't do anything - the ray just remains cast and it doesn't teleport. The only difference I'm able to see in the script is that Unity made me update GetCurrentRaycastHit to TryGetCurrent3DRaycastHit. Any thoughts on what I might be missing?
As far as I've been able to tell, GetCurrentRayCastHit still works. Though I am trying to figure out a Flicking issue with my Ray. Are you sending the TeleportQueueRequest? Just switch over to TryGetCurrent3DRaycastHit and it seems to be working out for me.
@@Breyyne I made the switch to TryGetCurrent3DRaycastHit. I am sending the request. My Update function looks like this:
void Update()
{
if (!_isActive)
return;
if (_thumbstick.triggered)
return;
if (!rayInteractor.TryGetCurrent3DRaycastHit(out RaycastHit hit))
{
rayInteractor.enabled = false;
_isActive = false;
return;
}
TeleportRequest request = new TeleportRequest()
{
destinationPosition = hit.point,
//destinationRotation = ,
};
provider.QueueTeleportRequest(request);
rayInteractor.enabled = false;
_isActive = false;
}
@@Breyyne Turns out it is working but not as expected. When I press the stick forward, the ray comes out but doesn't teleport me. If I hold the grip down and then push the stick forward, the ray comes out and teleports me.
Join the discord if you're still having issues and we can help you troubleshoot!
Hello Justin,
Thank you for this amazing tutorial!
One question though, because I am a complete beginner to coding: in visual studio 2019, although the predictions work, the visuals are different to your in the tutorial. is there some integration settings that I have to implement in my options?
The code editor I use is JetBrains Rider, so it'll look a little different
@@JustinPBarnett based
hi I got issue where the rays don't work and the move on controllers could you please help thanks
The ray casted from the hand is rotated 90 degrees on the Z axis. Any idea of how to correct this?
Try creating an empty game object as a child of each controller and rotate that to where you like it. Then you can move the ray interactor and line renderer component to the child object and that should work.
@@JustinPBarnett thanks!
Thanks for the tutorial. I have a question that if I use the Teleportation Manager script in the video, I can teleport to the area which does not have "Teleportation Area" script. However, my expectation is to teleport only on teleport areas, so could you give any suggestions to solve this problem?
Have you solved the problem?
Thank you Justin^^ You're awesome~
Thanks so much!!
Hi Justin, Thank you for the great tutorial. This have an small issue, When you try this on a plane without "Teleportation Area" Script attached, instead include teleportation anchors, movement is bit weird and it does teleport within that plane without the "Teleportation Area" script. Also this does cause positioning issues when we teleport into anchors. Can you suggest solution to fix this? Thank you in advance!
Teleporting onto anchors will move the player to that exact spot. It's different than a teleportation area. If you're still having issues join the Discord and we can help you troubleshoot in #dev-help!
Any reason I can’t see the channels in Discord, only welcome, landing page and chat with Justin?
Did you accept the rules?
@@JustinPBarnett how do I do that, I just read them?
hello, I have a small problem involving teleportation. I'm instantiating the player in the scene because the phase is a multiplayer one, however the "teleportation area" script that is on the ground for the use of the teleport only recognizes the "teleportation provider" script of the player if he is already in the scene when the player comes. how to solve it? I already tried dragging and dropping the script directly from the prefab to be instantiated but it didn't work...
You could set the references inside the start method of the Teleportation Manager that was created here. This is just an example for one teleport object, if you have multiple areas or anchors you need to do some kind of loop.
void Start()
{
var teleportArea = FindObjectOfType();
teleportArea.teleportationProvider = GetComponent();
// here comes the other code from this tutorial
}
This method works fine with Quest2 joystick or controllers with a joystick but is there a way to make this work with HTC Vive Wand Controller cause the Keypad auto teleport on pointing even if i dont release it. I can't find the way to put this on the KeyPad Press instead of Touch
You'll need to go into the Input Actions and find the HTC Vive Wand controller option and pick the specific input you want to use from that. So around 8:30 instead of using those action maps you can create your own specific one to use and map to.
@@JustinPBarnett But is it possible to make both controllers work in same app ? Like is it possible in script to detect which system i am using and call the actions according to the headset ?
@@lacoors Tbh I haven't found a good way to detect what controller is being used yet. It should be possible, but I'm not sure how
Why does the XR Rig have to be at 0, 0, 0. What should i do if i am trying to play from a different location?
It doesn’t have to be! You can start from anywhere. That was just me being OCD 😅
I don't see the problem about setting the rotation about the thumbstick position, just save the thumbstick vector2 when it' is greater that 0.9f for example, and calculate the rotation with that
Thanks for the great tutorial. I have a weird behaviour on my project. the teleportation is a bit far than expected although the teleportation area is not that wide. do you know what might be the reason for that?
You can decrease the length of the raycast if you don't want the player to teleport as far
Hi Justin! I want to be teleported with the XR Interaction Toolkit using a button. (where ı want) It doesn't happen when I call TeleportAnchor for the button. How can I do it?
You'll have to call the teleport provider when your button is pressed and provide a location to be teleported to
@@JustinPBarnett Thank you💥
Hello Justin! I am currenty using your tutorials for my bachelor's degree and I have a problem with this part. I followed your tutorial to animate hands beforehand and after doing this tutorial my rays do not cast anymore and I cannot teleport. Is there any solution for this, or did I mess up something? I am also seeing that my Line Renderer associated to my controller automatically disables itself when I enter play mode. Thanks in advance!
ich like your stuff a lot...thx!! one suggestion: your cuts are often very fast, so that i can almost not follow what you are doing.. a little little bit slower might be better :)
Thanks for the tip!
I have done this but the line is not always on the hands in middle of the plate
Great video! How do I teleport using Eye Gaze Interaction?
Haven't looked into that yet...
HI,
Great tutorial.
Everything works fine in unity itself, but when i build it to android device (quest2) it doesn't work correctly. When i'm pushing the thumbstick forward it teleports right away, without releasing the thumbstick.
Any idea what the problem is?
Try this:
if (_thumbstick.ReadValue() != Vector2.zero)
return;
// if (_thumbstick.triggered)
// return;
@@ChristianSasso This fixed it for me. thank you!
👆
In my case i kept teleporting, so I managed to fix it when you disable the rayInteractor and isActive variable at the end of your update
Great tutorial !
Thank you! Cheers!
Super clear and helpful! I got this one and the hands to work but now my grabbables are no longer grabbable. What do you think I broke?
Are all the layers set correctly and not conflicting?
@@JustinPBarnett Thanks for the reply & good question! It might have something to do with the models I downloaded (temp models) for the scene. When I use a basic sphere I can grab via the ray, ideal case I could grab with the hands from previous tutorial. I'll have to try it with the real models once I get them.
Hi Justin, i was trying to setup the teleportation and i am using a plane because i made a room in probuilder and inverted the uvs of a cube to make it so i can't use it for the teleportation zone. when i press the trigger to move and then release to choose where i want to teleport i shoot across the room and im unable to get to a specific location like in the middle of the room can you try help? thanks!
I followed everything exactly but I don;t seem to teleport to the hit point but flying so fast around!
Join the discord and we can help you troubleshoot!
I found this comment below "This teleportation method has nice behaviour in the editor, but in the android build, teleportation happens immediately when I press the joystick" Anyone found the solution? Thanks!
Your videos are amazing, help me a lot!!
I'm having the same thing - I had this working 2 weeks ago and then I come back to my project this week and I'm getting this happen now
Hmmm I feel like I've seen this guy... great content!
Hey, thanks!
Hey Justin, awesome tutorial as always, got an issue, i managed to get everything working but the reticle wont appear when i add it, any ideas?
Looking forward to your updated video. Followed the this tutorial and manipulated it to my liking. But the right hand controller is still active too! It teleports on grip release, which is super annoying because I'm using the right controller to interact with grabbables. If I don't point at a grabbable I get teleported. In the XRI RightHand Locomotion action map I removed all the Bindings from the Actions (Teleport Select, Teleport Mode Activate and Teleport Cancel) in the XRI Default Input Actions...
Yea definitely need to do an updated one soon
I inadvertently updated the XR Interaction Toolkit to the latest version (2.0.1). Typical newbie mistake. Ignored the warning that it was going to break the project. I could have used Collab to go back to the original version, but thought it might be interesting to fix the breaks that happened. The XRI Default Input Actions are very different. It broke the navigation on the left hand totally, although the right turn was still working nicely. Still testing a few more changes. I'll try to post them here and on the Discord. Has anyone tried this 2.0.1 version yet?
I ran into the same issue. The ActionMap has changed with the update. Use these instead in the c# script:
var activate = actionAsset.FindActionMap("XRI LeftHand Locomotion").FindAction("Teleport Mode Activate");
var cancel = actionAsset.FindActionMap("XRI LeftHand Locomotion").FindAction("Teleport Mode Cancel");
_thumbstick = actionAsset.FindActionMap("XRI LeftHand Locomotion").FindAction("Move");
If you're still having issues join the Discord and we can help you troubleshoot in #dev-help!
@@EchteTuber This worked! You are a genius
Hi Justin, thanks for the tutorial. Do you plan on making an updated tutorial for Unity 2021, It looks like some of the API's have changed and this no longer works :( also in future videos showing the full line of code and going a bit slower when creating the variables/autofilling would really help out a lot.
I definitely need to make an updated teleportation video
@12:01 No idea what you did here ?
I believe he is using Rider for coding which has shortcuts for such things as adding declarations for Variables that you add in later.
Yea I use JetBrains Rider, so I just have some hotkeys that I forget to mention sometimes
I really liked the tutorial it was easy to follow and easy to implement.
Not sure if anyone proposed a solution but I did manage to get the facing issue resolved. Not sure if it's the best solution but it does work.
I created a standalone GameObject to use as a recticle. I gave the object an obvious "front", enable, and place it at the hit point whenever the rayInteractor "isActive".
There's a little math to convert the 2d axis into a rotation angle
Vector2 directionVec = thumbStickAction.ReadValue();
float angle = Mathf.Atan2(directionVec.y, directionVec.x) * Mathf.Rad2Deg;
landingReticle.transform.rotation = Quaternion.Euler(new Vector3(0, -angle, 0)); // This is assuming you're rotating around the Y axis.
Some minor adjustments to align the objects "forward" with the angle you have to add 2 lines to the teleportRequest code.
teleportRequest.matchOrientation = MatchOrientation.TargetUpAndForward; //
Thanks! And good way to fix that
HELP Please. Script is telling me that it does not recognize - QueueTeleportRequest any idea how to fix it?
If you're still having issues join the Discord and we can help you troubleshoot in #dev-help!
This teleportation method has nice behaviour in the editor, but in the android build, teleportation happens immediately when I press the joystick
same for me, it is almost instant in Quest 2
@@silwer222 I done it in another way, I can share my solution if you need it
@@andriy_z It would be great :D
Андрій Зімбіцький please share it
@@andriy_z I would like to know how you fixed it as well, please.
Anyone figure out the rotation?
Also anyone else having the bug where you don't stop teleporting?
Yea there's a few bugs with this one, I'm trying to do an update video about teleporting pretty soon
@@JustinPBarnett It would be great if you could add to the update how to change the length of the teleport arc based on the amount the thumb stick is pressed Although it would likely then need to activate with trigger rather than release.
Hi Justin, I've solved the issue you have with the teleportation rotation in the video. But I'm not fully sure how to send you an email or message. Please let me know how to followup or I can explain in the comments.
Just shoot me an email or a message in the Discord!
how do you setup project using xr interaction toolkit 2.0
Check out my 2022 setup video
In regards to directional teleporting, you might find an answer by seeing how Oculus implemented it in their Unity integration. This tutorial implements what you're describing: ua-cam.com/video/r1kF0PhwQ8E/v-deo.html
Ooo thanks! Definitely going to look into this
I should mention that while mathematically the magnitude of the thumbstick pressing against the socket is equal to 1, in practice the number might be smaller (0.99 for example). The same goes for the center being point (0,0). You may want to use inequalities in the if statements to allow for a deadzone and a tolerance for the thumbstick.
That video uses the older OVR system. And, it's from 2019. I'm not sure it will be supported in the future.
我不知道你是否已经解决关于传送方向的问题,在新的xr版本中可以参考TeleportationArea组件的MatchDirectionalInput属性,这应该可以解决你的问题!
That’s not new one there a new one with 5 on there now
Oh I highly recommend the new version now instead of this video. This one is outdated
@@JustinPBarnett I still can,t get the teleport to work with controller on new input system I tried changing the code when I turn off teleport controller it works but I want to turn off by button
2018-we teleported with basic animation, beautiful spline and round point model for it... 2021... wtf man?))
ask Unity 🤷♀️
Not for beginners. This tutorial goes way too fast and is not very clear.
Did you watch this video first?? ua-cam.com/video/1VC3ZOxn2Lo/v-deo.html
Amazing video, I had the same problem as some people that the trigger wasnt working correctly, changed to:
if (_thumbstick.ReadValue() != Vector2.zero)
return;
And it worked just fine. Another problem was the teleport was going too far away but I figured that the teleportation was being activated more than once so after I do the TeleportRequest I just added this two lines:
provider.QueueTeleportRequest(request);
rayInteractor.enabled = false;
_isActive = false;
Hope this helps someone :)