How to Teleport in Unity VR with XR Interaction Toolkit

  Рет қаралды 43,541

Justin P Barnett

Justin P Barnett

Күн бұрын

It's what we've all dreamed about since we were kids. What would it be like to teleport? Use Unity's new input system combined with the XR Interaction Toolkit. This method of VR locomotion is just a blip away!
Hey, devs! Teleportation is one of the primary methods of locomotion in VR games. XR Interaction Toolkit has a preset teleportation option, but honestly....it's garbage. So in this video, we will fix the default actions to resemble something more game-ready! Oh, and there's a challenge 😉
📺 Watch Next: • What Do I Need to Beco...
🥽 Enroll in the (now FREE) VR Creator Academy: skool.com/vrcreatoracademy
⌚ Timestamps
0:00 Subscribe!
0:13 Setup XR Rig
2:12 Teleportation Locomotion System
3:10 Teleportation Area vs Anchor
3:58 Testing the Default Teleport Method
5:08 Update Line Visuals
6:21 Sweet Sweet Code
15:08 My Challenge to YOU
17:10 Testing
17:57 Like!
19:00 Comment!
#vr #teleportation #unity

Пікірлер: 212
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Download the Project (for FREE): www.vrcreators.io/codedownloads
@riverboatgambler3401
@riverboatgambler3401 17 күн бұрын
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!
@MatanNaveh
@MatanNaveh 3 жыл бұрын
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.
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Wow, I really appreciate all the praise and encouragement Matan! Thanks so much! (And getting a VR headset is SO fun!)
@cirelachlan
@cirelachlan 2 жыл бұрын
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.
@ishakgamingspider8743
@ishakgamingspider8743 2 жыл бұрын
Your channel is very cool man I didn't know anything about vr but when I found your channel my life changed❤
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Welcome aboard!
@tczhou9969
@tczhou9969 3 жыл бұрын
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
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Thanks!
@hans-henrikjensen
@hans-henrikjensen 2 жыл бұрын
You can find an example on discord in vr-resources
@shanghai752
@shanghai752 Жыл бұрын
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!
@jeremyledermann4281
@jeremyledermann4281 Жыл бұрын
Thanks a lot, I was on this issue for like 2hours, you save me !
@vitchi
@vitchi Жыл бұрын
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?
@danread1217
@danread1217 2 жыл бұрын
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).
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
That's actually a really great suggestion! Should work pretty good
@danread1217
@danread1217 2 жыл бұрын
@@JustinPBarnett Yep- works an absolute treat! Will write it up when I get 5 minutes...
@fateshow5303
@fateshow5303 2 жыл бұрын
Great videos, sending my support, keep doing what yr doing yr great!
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Thank you so much!!
@gtxo2104
@gtxo2104 3 жыл бұрын
these vr tutorials are very cool I have to say. I am making a spiderman game, imagine how sick that would b in VR
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
That would be incredible!!
@haraldgundersen7303
@haraldgundersen7303 3 жыл бұрын
You should try out vrinteraction framework by Bearded Ninja
@TwistdRabbit
@TwistdRabbit 2 жыл бұрын
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?
@lop258
@lop258 2 жыл бұрын
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?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Just add a teleportation area to the mesh!
@azataiabylbek5262
@azataiabylbek5262 2 жыл бұрын
Thank you Justin^^ You're awesome~
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Thanks so much!!
@andreigtx1711
@andreigtx1711 2 жыл бұрын
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!
@CrossTwnAuto
@CrossTwnAuto 2 жыл бұрын
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!
@lovelymammoth
@lovelymammoth 2 жыл бұрын
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?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
The code editor I use is JetBrains Rider, so it'll look a little different
@austincottle6789
@austincottle6789 Жыл бұрын
@@JustinPBarnett based
@olivername
@olivername Жыл бұрын
hi I got issue where the rays don't work and the move on controllers could you please help thanks
@jakewarr6942
@jakewarr6942 2 жыл бұрын
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.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
I definitely need to make an updated teleportation video
@alo2a7eta
@alo2a7eta 2 жыл бұрын
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?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
You can decrease the length of the raycast if you don't want the player to teleport as far
@tannersmith8050
@tannersmith8050 2 жыл бұрын
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!
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
You'd have to override the teleport method and add a counter to it
@pozlong8614
@pozlong8614 2 жыл бұрын
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?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Are all the layers set correctly and not conflicting?
@pozlong8614
@pozlong8614 2 жыл бұрын
@@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.
@mrstruijk
@mrstruijk 2 жыл бұрын
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.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Glad you got it working!
@jacobclaytor5999
@jacobclaytor5999 2 жыл бұрын
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.
@parse_error
@parse_error 2 жыл бұрын
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 ;)
@eTxsicWtKUEbBwaQicQJuOPKgW
@eTxsicWtKUEbBwaQicQJuOPKgW 2 жыл бұрын
OHHHHHHHHHHHHHHHHHHHHHHHHHHH IT WORKS PREFECTLY!
@winn8888
@winn8888 2 жыл бұрын
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.
@olivername
@olivername Жыл бұрын
I have done this but the line is not always on the hands in middle of the plate
@sebastien4507
@sebastien4507 Жыл бұрын
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
@EchteTuber
@EchteTuber 2 жыл бұрын
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...
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Yea definitely need to do an updated one soon
@sakunamadushanka6382
@sakunamadushanka6382 2 жыл бұрын
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!
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
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!
@JustPhil
@JustPhil 2 жыл бұрын
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 :)
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Thanks for the tip!
@user-kj1fq8vn8f
@user-kj1fq8vn8f 2 жыл бұрын
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?
@lenoardliu2134
@lenoardliu2134 Жыл бұрын
Have you solved the problem?
@Andrew-he5gj
@Andrew-he5gj 3 жыл бұрын
Great tutorial !
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Thank you! Cheers!
@hansshadow360
@hansshadow360 2 жыл бұрын
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.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord and we can help you troubleshoot!
@lacoors
@lacoors 3 жыл бұрын
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 ???
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
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!
@lacoors
@lacoors 3 жыл бұрын
@@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 :)
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
@@lacoors Yup! good catch & solution
@greg2fs
@greg2fs Жыл бұрын
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
@connormarkus8398
@connormarkus8398 3 жыл бұрын
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?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
It doesn’t have to be! You can start from anywhere. That was just me being OCD 😅
@xZeroCCx
@xZeroCCx 3 жыл бұрын
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
@JustinPBarnett 3 жыл бұрын
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.
@xZeroCCx
@xZeroCCx 3 жыл бұрын
@@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
@xZeroCCx 3 жыл бұрын
Firing the TP on stick release works, but unless you find an invalid target there isn't a way to cancel our teleport right?
@Ariel16283
@Ariel16283 2 жыл бұрын
@@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.
@Ariel16283
@Ariel16283 2 жыл бұрын
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.
@chills_20
@chills_20 3 жыл бұрын
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?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
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?
@JayPatel-sw2fh
@JayPatel-sw2fh 3 жыл бұрын
@@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?
@rodrigo.cs.machado
@rodrigo.cs.machado Жыл бұрын
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...
@timpixel3679
@timpixel3679 Жыл бұрын
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 }
@DanielSantallaa
@DanielSantallaa 3 жыл бұрын
The ray casted from the hand is rotated 90 degrees on the Z axis. Any idea of how to correct this?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
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.
@DanielSantallaa
@DanielSantallaa 3 жыл бұрын
@@JustinPBarnett thanks!
@Atlar
@Atlar 2 жыл бұрын
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
@JustinPBarnett 2 жыл бұрын
Thanks! And good way to fix that
@lacoors
@lacoors 3 жыл бұрын
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
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
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.
@lacoors
@lacoors 3 жыл бұрын
@@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 ?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
@@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
@mayadaaq711
@mayadaaq711 2 жыл бұрын
I followed everything exactly but I don;t seem to teleport to the hit point but flying so fast around!
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord and we can help you troubleshoot!
@russellgilbertdecastro7031
@russellgilbertdecastro7031 3 жыл бұрын
Hmmm I feel like I've seen this guy... great content!
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Hey, thanks!
@shaynemcgregor1450
@shaynemcgregor1450 3 жыл бұрын
I ran into a null reference exception and it has something to do with the _thumbstick variable, but I don't know how to fix it NullReferenceException: Object reference not set to an instance of an object TeleportationManager.Update () (at Assets/TeleportationManager.cs:33)
@HairySeagull
@HairySeagull 2 жыл бұрын
Yea what is going on? Did you fix it?
@sedatunali407
@sedatunali407 2 жыл бұрын
@@HairySeagull Make sure you didn't add var to the _thumbstick in the start method. I did at first by copying the activate and cancel variables above.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
👆
@knightcube
@knightcube 2 жыл бұрын
Great video! How do I teleport using Eye Gaze Interaction?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Haven't looked into that yet...
@ArendRaifsnider
@ArendRaifsnider 3 жыл бұрын
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?
@Breyyne
@Breyyne 3 жыл бұрын
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.
@ArendRaifsnider
@ArendRaifsnider 3 жыл бұрын
@@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; }
@ArendRaifsnider
@ArendRaifsnider 3 жыл бұрын
@@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.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Join the discord if you're still having issues and we can help you troubleshoot!
@bluurayr
@bluurayr 2 жыл бұрын
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?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
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)
@bluurayr
@bluurayr 2 жыл бұрын
@@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
@yasarbaba2413
@yasarbaba2413 3 жыл бұрын
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?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
You'll have to call the teleport provider when your button is pressed and provide a location to be teleported to
@yasarbaba2413
@yasarbaba2413 3 жыл бұрын
@@JustinPBarnett Thank you💥
@Frowdy325
@Frowdy325 3 жыл бұрын
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?
@ChristianSasso
@ChristianSasso 3 жыл бұрын
Try this: if (_thumbstick.ReadValue() != Vector2.zero) return; // if (_thumbstick.triggered) // return;
@danielgarciagonzalez2391
@danielgarciagonzalez2391 2 жыл бұрын
@@ChristianSasso This fixed it for me. thank you!
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
👆
@BonCreations
@BonCreations 3 жыл бұрын
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
@JustinPBarnett 3 жыл бұрын
Do you have an action of that name set up?
@BonCreations
@BonCreations 3 жыл бұрын
@@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
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
@@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
@BonCreations
@BonCreations 3 жыл бұрын
@@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?
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
@@BonCreations hmmm so you’re trying to use continuous movement and teleportation at the same time?
@InteractViz
@InteractViz 2 жыл бұрын
HELP Please. Script is telling me that it does not recognize - QueueTeleportRequest any idea how to fix it?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
If you're still having issues join the Discord and we can help you troubleshoot in #dev-help!
@ctedin1
@ctedin1 2 жыл бұрын
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?
@EchteTuber
@EchteTuber 2 жыл бұрын
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");
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
If you're still having issues join the Discord and we can help you troubleshoot in #dev-help!
@XxXSkidXxX
@XxXSkidXxX 2 жыл бұрын
@@EchteTuber This worked! You are a genius
@veaarthur3655
@veaarthur3655 2 жыл бұрын
Why did you leave Teleport Mode Cancel set to "gripPressed"?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
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.
@stephenmackenzie9016
@stephenmackenzie9016 2 жыл бұрын
Any reason I can’t see the channels in Discord, only welcome, landing page and chat with Justin?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Did you accept the rules?
@stephenmackenzie9016
@stephenmackenzie9016 2 жыл бұрын
@@JustinPBarnett how do I do that, I just read them?
@MEJHarrison
@MEJHarrison 3 жыл бұрын
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
@JustinPBarnett 3 жыл бұрын
Sounds like you're running the teleport action on stick pushed instead of stick released and put back to 0
@MEJHarrison
@MEJHarrison 3 жыл бұрын
@@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)) {
@MEJHarrison
@MEJHarrison 3 жыл бұрын
the _thumbstick variable is defined as: private InputAction _thumbstick;
@MEJHarrison
@MEJHarrison 3 жыл бұрын
The _thumbstick variable is set here: _thumbstick = actionAsset.FindActionMap("XRI LeftHand").FindAction("Move"); _thumbstick.Enable();
@MEJHarrison
@MEJHarrison 3 жыл бұрын
@@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.
@WolfServant
@WolfServant 2 жыл бұрын
Anyone figure out the rotation? Also anyone else having the bug where you don't stop teleporting?
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Yea there's a few bugs with this one, I'm trying to do an update video about teleporting pretty soon
@GiantBean
@GiantBean 2 жыл бұрын
@@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.
@wscreamer
@wscreamer 2 жыл бұрын
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.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Just shoot me an email or a message in the Discord!
@joeysmith3465
@joeysmith3465 2 жыл бұрын
how do you setup project using xr interaction toolkit 2.0
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Check out my 2022 setup video
@curtisturpin9389
@curtisturpin9389 2 жыл бұрын
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.
@matiaspina2323
@matiaspina2323 11 ай бұрын
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!!
@jakehartnoll6625
@jakehartnoll6625 11 ай бұрын
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
@MING1130
@MING1130 Жыл бұрын
我不知道你是否已经解决关于传送方向的问题,在新的xr版本中可以参考TeleportationArea组件的MatchDirectionalInput属性,这应该可以解决你的问题!
@jack8750
@jack8750 3 жыл бұрын
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: kzbin.info/www/bejne/qGLOd2OGndyEbqc
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Ooo thanks! Definitely going to look into this
@jack8750
@jack8750 3 жыл бұрын
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.
@ctedin1
@ctedin1 2 жыл бұрын
That video uses the older OVR system. And, it's from 2019. I'm not sure it will be supported in the future.
@andriy_z
@andriy_z 3 жыл бұрын
This teleportation method has nice behaviour in the editor, but in the android build, teleportation happens immediately when I press the joystick
@silwer222
@silwer222 3 жыл бұрын
same for me, it is almost instant in Quest 2
@andriy_z
@andriy_z 3 жыл бұрын
@@silwer222 I done it in another way, I can share my solution if you need it
@silwer222
@silwer222 3 жыл бұрын
@@andriy_z It would be great :D
@HaniSharif
@HaniSharif 3 жыл бұрын
Андрій Зімбіцький please share it
@danielgarciagonzalez2391
@danielgarciagonzalez2391 2 жыл бұрын
@@andriy_z I would like to know how you fixed it as well, please.
@ScratchedWinter
@ScratchedWinter 3 жыл бұрын
@12:01 No idea what you did here ?
@Breyyne
@Breyyne 3 жыл бұрын
I believe he is using Rider for coding which has shortcuts for such things as adding declarations for Variables that you add in later.
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
Yea I use JetBrains Rider, so I just have some hotkeys that I forget to mention sometimes
@westparezal
@westparezal 2 жыл бұрын
2018-we teleported with basic animation, beautiful spline and round point model for it... 2021... wtf man?))
@JustinPBarnett
@JustinPBarnett 2 жыл бұрын
ask Unity 🤷‍♀️
@olivername
@olivername Жыл бұрын
That’s not new one there a new one with 5 on there now
@JustinPBarnett
@JustinPBarnett Жыл бұрын
Oh I highly recommend the new version now instead of this video. This one is outdated
@olivername
@olivername Жыл бұрын
@@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
@katrinaburch4752
@katrinaburch4752 3 жыл бұрын
Not for beginners. This tutorial goes way too fast and is not very clear.
@JustinPBarnett
@JustinPBarnett 3 жыл бұрын
Did you watch this video first?? kzbin.info/www/bejne/Z4emZI2FrdNlgtE
@Kiddrelax
@Kiddrelax 2 жыл бұрын
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 :)
The Secret to Virtual Reality: Make VR Games Without the Headset
20:05
Justin P Barnett
Рет қаралды 30 М.
VR в Unity: XR Interaction Toolkit - Часть 1 (Основы)
13:54
KINDNESS ALWAYS COME BACK
00:59
dednahype
Рет қаралды 161 МЛН
Cat Corn?! 🙀 #cat #cute #catlover
00:54
Stocat
Рет қаралды 15 МЛН
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 11 МЛН
How to Jump in VR using Unity's New Input System
17:29
Justin P Barnett
Рет қаралды 22 М.
VR Teleport Area and Snap Rotation in Unity 2022.2
6:19
Meetras
Рет қаралды 6 М.
Make VR DOORS IN UNITY with NO CODE!
8:09
Daniel Stringer
Рет қаралды 11 М.
Setup Teleporting in Unity XR Interaction Toolkit
9:16
Ryan Murray
Рет қаралды 4,7 М.
Unity's New Input System - A Beginners Guide
17:29
Justin P Barnett
Рет қаралды 26 М.
Hunted, Hunting, Salvaging, Traveling
9:24
ghost955
Рет қаралды 24
How to use VR Sockets (and XR Interaction Toolkit) in Unity 2021.2
19:29
Justin P Barnett
Рет қаралды 25 М.
How to Render Faster In Blender Cycles
9:11
BadgerBricks
Рет қаралды 24 М.
Unity VR XR Interaction Toolkit -Locomotion Move & Snap Turn
7:01
KINDNESS ALWAYS COME BACK
00:59
dednahype
Рет қаралды 161 МЛН