2023 Unity VR Basics - Teleportation

Fist Full of Shrimp
20 Sept 202311:11

Summary

TLDRThis video script offers a comprehensive guide to implementing teleportation in VR using Unity's XR Interaction Toolkit. It covers setting up a teleportation provider, interactor, and anchor or area. The tutorial explains how to customize teleportation with delay times, interaction layers, and reticle colors. It also details configuring the XR controller for input actions, managing interaction groups to avoid conflicts, and enabling smooth or snap turns for user comfort. The script concludes with a fully functional teleportation system that complements continuous movement and object interaction.

Takeaways

  • 🚀 The script discusses implementing teleportation in VR, focusing on the components needed for a functional teleportation system.
  • 🛠️ A 'teleportation provider' is essential for setting up teleportation, which can be added to a Locomotion system.
  • ⏱️ The teleportation provider includes a 'delay time' feature to add a delay before teleportation, enhancing user comfort.
  • 🔭 The 'teleportation interactor' is responsible for the interaction with the environment, shooting out a ray to indicate the teleportation target.
  • 🎯 The 'teleportation anchor' or 'teleportation area' are destinations where users can teleport to within the VR environment.
  • 🎨 Customization options are available for the teleportation interactor, including colors for valid and invalid targets, and the reticle design.
  • 🔧 The script guides on how to fix issues like setting the correct interaction layer for teleportation in the XR Interaction Manager.
  • 🧩 The importance of adding an XR controller to the interactor for independent control over select actions is highlighted.
  • 🔄 The script explains how to set up a teleportation area to allow for area-based teleportation, rather than just point-to-point.
  • 🎮 The process of customizing input actions for the right hand controller to control teleportation is detailed, including the use of thumbsticks.
  • 🔄 The video concludes with a demonstration of a fully functional teleportation system integrated with continuous movement and object interaction.

Q & A

  • What are the main components required to implement teleportation in VR?

    -The main components required for teleportation in VR include a teleportation provider, a teleportation interactor, and a teleportation area or anchor.

  • How does the teleportation provider work in the VR system?

    -The teleportation provider is added to the Locomotion system and handles the logic for when and how teleportation is activated, including a delay time before teleportation occurs.

  • What is the purpose of the delay time in the teleportation provider?

    -The delay time in the teleportation provider is used to add a brief wait period after teleportation is activated, which can be used to add visual effects like a vignette for user comfort.

  • How is the teleportation interactor different from other interactors?

    -The teleportation interactor is responsible for interacting with the world to perform the teleport action, typically using a ray that shoots out from the controller to select the teleportation target.

  • Why is the interaction layer mask important for the teleportation interactor?

    -The interaction layer mask, specifically set to 'teleport', is crucial for the teleportation interactor to correctly identify valid targets for teleportation within the VR environment.

  • What is a teleportation anchor and how does it differ from a teleportation area?

    -A teleportation anchor is a specific point in the VR environment that users can teleport to, whereas a teleportation area allows users to teleport anywhere within a defined space.

  • How can users customize the orientation upon teleporting to a location?

    -Users can customize the orientation upon teleporting by adjusting the 'Match Orientation' setting on the teleportation anchor, which determines the facing direction based on the anchor's axis.

  • What is the role of the XR controller in the teleportation interactor?

    -The XR controller on the teleportation interactor is used to capture input data from the user's VR controller, allowing for actions like selecting a teleportation target.

  • How can the teleportation interactor be customized to use different input actions?

    -The teleportation interactor can be customized to use different input actions by assigning specific actions like 'teleport select' to the select action and select action value fields within the XR controller component.

  • What is the purpose of the XR interaction group in the context of teleportation?

    -The XR interaction group is used to manage and prioritize different interaction types, such as teleportation, direct interaction, and poking, ensuring that they do not conflict with each other.

  • How does the action-based controller manager tie together the teleportation system?

    -The action-based controller manager ties together the teleportation system by assigning specific actions to the right hand controller, allowing for smooth transitions between different locomotion modes like continuous movement, teleportation, and snap turns.

Outlines

00:00

🚀 Setting Up Teleportation in VR

The paragraph discusses the process of implementing teleportation in a VR project, highlighting the need for a teleportation provider, interactor, and an area to teleport to, such as a teleportation anchor or area. The teleportation provider is added to the Locomotion system, and a delay time can be adjusted for comfort. The interactor, which shoots a ray for interaction, is set up using a prefab from the XR Interaction Toolkit. The paragraph also covers the creation of a teleport layer in the XR Interaction Manager and the customization of the teleportation interactor, including the reticle and colors for valid and invalid targets.

05:02

🛠️ Customizing Teleportation Controls and Area

This section delves into enhancing the teleportation controls by modifying the select action and adding an XR controller to the interactor. It details the process of setting up the teleportation area, ensuring it's on the correct layer and can be customized for orientation matching. The paragraph also addresses the removal of unnecessary model prefabs and the setup of an XR interaction group for the right hand controller to manage interactions without overlap. Finally, it explains the addition of an action-based controller manager to tie all components together, allowing for smooth teleportation and rotation using the thumbstick.

10:03

🎮 Finalizing Teleportation and Locomotion Integration

The final paragraph covers the activation of both continuous and snap turn providers in the Locomotion system, enabling smooth and snap turning options. It also discusses the setup of the turn system to allow for either smooth or snap turns, with a preference for snap turns as demonstrated. The video concludes with a demonstration of the fully functional teleportation system, where the user can snap turn, rotate the reticle with the thumbstick, and teleport to the selected location. The paragraph ends with an acknowledgment of Patreon subscribers and a sign-off, promising more content in the future.

Mindmap

Keywords

💡Teleportation

Teleportation in the context of the video refers to a method of virtual reality (VR) locomotion where a user instantly moves from one location to another within the virtual environment. This is a key concept as it is the primary focus of the tutorial, with the script detailing how to implement teleportation in a VR project. The video discusses various components needed for teleportation, such as a teleportation provider and interactor.

💡Locomotion System

The Locomotion System is a core component in VR development that handles how users move and navigate within a virtual environment. In the script, it is mentioned as the place where the continuous move provider and teleportation provider are added, indicating its role in managing different movement mechanics in VR.

💡Teleportation Provider

A teleportation provider is a component in the VR system that facilitates the teleportation mechanic. The script explains how to add this provider to the Locomotion System and configure it, including setting a delay time that can be used to enhance user comfort during teleportation.

💡Teleportation Interactor

The Teleportation Interactor is an element that interacts with the virtual world to enable teleportation. It is described in the script as a 'Ray' that shoots out from the controller, allowing the user to select a point to teleport to. The video also covers how to customize this interactor to work with the right hand controller.

💡Teleportation Anchor

A Teleportation Anchor, as mentioned in the script, is a specific point in the VR environment that users can teleport to. The video explains how to set up this anchor using a prefab from the XR Interaction Toolkit, which is a pre-made component that simplifies the development process.

💡Teleportation Area

In contrast to a single anchor point, a Teleportation Area allows users to teleport anywhere within a defined region. The script describes how to create a custom teleportation area by adding a component to a plane in the scene, making the entire surface teleportable.

💡Interaction Layer Mask

The Interaction Layer Mask is a setting that determines which objects in the VR environment can be interacted with by the user. The script highlights the need to create and assign a specific layer mask called 'teleport' for the teleportation interactor to function correctly.

💡XR Interaction Manager

The XR Interaction Manager is a tool used to manage various interaction layers and settings in a VR project. The video script describes how to use this manager to fix issues with the interaction layer and to set up the teleportation layer mask.

💡Reticle

A Reticle in VR is a visual indicator that appears where the user is looking or pointing, often used for aiming or selection. The script explains how to customize the reticle's appearance and behavior, such as changing it when a valid or invalid target is selected.

💡XR Controller

An XR Controller is a device used to interact with a VR environment. The script discusses adding an XR controller component to the teleportation interactor to customize input actions, such as changing the select action from the grip button to a thumbstick input.

💡XR Interaction Group

The XR Interaction Group is a component that manages the interaction priorities between different interactors on the same controller. The video script describes how to set up an interaction group for the right hand controller to ensure that the teleportation interactor does not conflict with other interactors.

Highlights

Introduction to teleportation as a method of movement in VR.

Requirement of a teleportation provider, interactor, and an area for teleportation.

Adding a teleportation provider to the Locomotion system.

Explanation of delay time in teleportation for comfort.

Selection of the right hand for the teleportation interactor.

Use of a prefab for the teleport interactor.

Customization of the interaction layer mask for teleportation.

Fixing the interaction layer in project settings for teleportation.

Customization options for teleportation colors and reticle.

Introduction of the teleportation area and its setup.

Customizing the teleportation area to match user orientation.

Testing the teleportation system in the scene.

Improving controls by changing select action for teleportation.

Adding an XR controller to the interactor for better input handling.

Setting up the XR interaction group for the right hand controller.

Adding an action-based controller manager to tie all interactions together.

Enabling smooth motion or snap turn options for user preference.

Final testing and demonstration of the complete teleportation system.

Acknowledgment of Patreon subscribers for their support.

Transcripts

play00:00

besides continuous movement the only

play00:02

other real way to move in VR is

play00:04

teleportation well I guess there's grab

play00:07

move but we're not talking about that

play00:08

today today we're talking about how to

play00:10

teleport so let's get in it now to get

play00:12

teleportation to work out our project

play00:13

we're going to need a few things we're

play00:15

going to need a teleportation provider a

play00:17

teleportation interactor and then

play00:19

finally an area that we can teleport to

play00:21

such as the teleportation anchor or well

play00:24

teleportation area which would be like

play00:26

this plane so let's kick things off and

play00:28

get a teleportation provider in to do

play00:30

that I'm going to throw it on our

play00:31

Locomotion system here and if you

play00:33

remember this is where I put the move

play00:35

continuous move provider and then we

play00:37

also have the turn or snap turn

play00:39

providers here and so I'm just going to

play00:41

add a component or actually I'm going to

play00:43

create an empty child and I'm going to

play00:45

name this teleportation provider

play00:48

and then we just add component

play00:50

and of course it's asking for a

play00:53

Locomotion system which I can just drag

play00:54

that here and then we also have this

play00:56

delay time and you can play with this if

play00:58

you want this will just add a delay once

play01:00

teleportation is activated essentially

play01:03

if you activate your teleportation it'll

play01:05

wait a second or two before it actually

play01:06

teleports you and you can use that to

play01:08

add in a vignette for Comfort but eh I

play01:11

think it's fine without it now next up

play01:13

is going to be our teleportation inner

play01:16

actor and so this is what's going to

play01:17

interact with the world and teleport

play01:19

it's going to be that Ray that shoots

play01:21

out so if we expand out here I think

play01:23

it's more natural to have it on the

play01:24

right hand and so we could customize

play01:26

this Ray that we already have in the

play01:28

scene I actually found out that there is

play01:31

a prefab that we can use so if we go

play01:33

into samples XR interaction toolkit and

play01:36

then go to prefabs and interactors you

play01:38

can find this teleport interactor so we

play01:41

just drag that onto the right hand

play01:42

controller and it should be set up for

play01:44

us for the most part one goofy thing

play01:46

that's not done here is if you look here

play01:48

it should work on an interaction layer

play01:51

mask called teleport but we don't have

play01:53

that and it's kind of funny because you

play01:56

think that they would just add that in

play01:58

considering well we're doing the XR

play02:00

interaction toolkit it should just add

play02:01

that layer but regardless I'm going to

play02:03

go ahead and drag in the XR interaction

play02:06

manager here

play02:08

let me show you what I'm talking about

play02:10

when I talk about the teleport layer

play02:12

needs to be there so if we go to Project

play02:13

settings and come to project validation

play02:16

this is where you can find errors pop up

play02:18

and it's saying right here that the

play02:20

interaction layer 31 should be set to

play02:22

teleport for teleportation Locomotion

play02:25

why they don't add this in because

play02:26

teleportation is pretty common I don't

play02:28

know so I'm just going to click fix and

play02:31

then if we came over here went to add

play02:33

layer you can see here it added user

play02:35

layer 31 teleport so I'm going to come

play02:37

back here and you can see it's already

play02:39

set itself to that so there you go now

play02:41

if you wanted to you can also customize

play02:43

colors and stuff here so this is the

play02:45

color for when we have a valid Target

play02:47

invalid Target or something's blocked

play02:49

you can also change the reticle here so

play02:52

that's going to be the little thing on

play02:54

the ground so if I double click this

play02:55

this is going to appear on the ground

play02:56

when we have at the very end of our

play02:58

array and then you can see what it looks

play03:01

like they also have a blocked one and

play03:03

it'll look like that and I'll have a

play03:04

little X now before we can do anything

play03:06

interesting with this Ray interact

play03:08

director and the provider we need a

play03:10

place to teleport to First otherwise

play03:12

we're just not going to be really able

play03:14

to interact with anything first let's

play03:16

start off with the teleportation area

play03:18

and again you can find a prefab for this

play03:21

under the xri interaction toolkit so

play03:24

samples XI interaction toolkit and then

play03:26

we're going to go into teleport and you

play03:28

can see here we have a Teleport anchor

play03:30

and teleport area so I'm going to drop

play03:32

this anchor into the scene and if I

play03:35

select it here we can see what we have

play03:37

we have a teleportation area and that's

play03:40

about it it's set to the teleport layer

play03:44

so that's good and then if you wanted to

play03:46

you can customize how this teleportation

play03:49

configuration works so match orientation

play03:51

so based on what we choose here it will

play03:54

determine how we're going to face when

play03:56

we teleport to this so right now it's

play03:58

set to Target up and forward and so it

play04:01

will use the y axis of this anchor and

play04:04

then it will use the Z access to

play04:06

consider what is forward and so when we

play04:09

teleport to it no matter if we were

play04:10

teleporting it from this side or this

play04:13

side once we teleport to this spot it's

play04:15

always going to be up and forward and

play04:17

that can be really good if you want to

play04:19

make sure that your users are going to

play04:21

maybe have a specific spot and you only

play04:22

want them to face a certain area and

play04:24

interact with things let's boot up the

play04:26

scene and see what we have and yeah now

play04:29

you can see that I hover over the anchor

play04:31

and if I press the grip button it'll

play04:34

teleport me to it so they go it works

play04:36

there we have it the teleport anchor but

play04:39

you know we're not really after the

play04:41

teleport anchor sir you can use it for a

play04:44

few clutch cases but really you're more

play04:47

interested in the teleport area in which

play04:49

we can make this whole area teleportable

play04:51

and so to do that I'm just going to

play04:53

select This Plane I'm going to add

play04:54

component and find teleport area and

play04:57

since we're not using the prefab here

play04:59

which well we could but you know I don't

play05:01

know I like having a custom teleport

play05:03

area but if we come back to the teleport

play05:05

area here that's on the plane we just

play05:07

need to make sure we set this to

play05:09

teleport and turn off the default there

play05:11

and now it should be ready now you can

play05:13

see that when I'm looking around I'm

play05:15

able to teleport anywhere on the

play05:16

teleportation area but I can't really

play05:19

rotate how I teleport and also I still

play05:22

have to use the grip button which kind

play05:23

of sucks so let's fix that now in order

play05:26

to improve our controls we're going to

play05:28

have to change how the teleport

play05:30

interactor considers the select action

play05:33

taking place so currently right now if

play05:35

we choose this you'll see that it should

play05:38

be using an XR controller for getting

play05:40

input data which you can find on the

play05:42

parent the right hand controller right

play05:44

here so it's using this and it's saying

play05:45

oh yeah the select action value is going

play05:48

to be well the select input which is the

play05:50

grip button so that's how it's choosing

play05:52

that but if we want it to have its own

play05:54

way of doing that then we're going to

play05:56

have to put an XR controller on the

play05:58

interactor itself so if we go to add

play06:00

component XR controller

play06:03

and you'll see we've put one here and

play06:05

you know what I do want it to be mostly

play06:07

based off the right hand controller so I

play06:09

am going to come back over here I'm

play06:11

going to select up here and the right

play06:14

controller default and then we'll just

play06:16

customize some things so again how this

play06:18

normally works is it will just go to the

play06:21

default parent Whoever has the XR

play06:22

controller but since this has one

play06:24

directly on it now it's going to default

play06:27

to this one now the things we need to

play06:29

customize here we aren't really using

play06:31

any position rotation anything we're not

play06:34

really using any of these so we're gonna

play06:36

go ahead and Mark these off and then for

play06:39

this the select action and select action

play06:41

value what we need is the teleport

play06:44

action and so this is going to be right

play06:47

here teleport select so I'm going to

play06:49

choose that for that and then also I'm

play06:52

going to also choose the same teleport

play06:54

select and make sure it's the right hand

play06:56

teleport select and if I double click

play06:58

this you can see this in the input

play07:00

actions what this is I'm going to expand

play07:03

this out and you can see right here for

play07:05

the teleport select it takes a value and

play07:08

then coming over here it's using the

play07:10

primary 2D axis so it is just kind of

play07:12

using that thumbstick that's how we

play07:14

select is once we push forward and

play07:16

release we have selected now another

play07:18

problem that you'll find here is when

play07:20

since we've added an XR controller for

play07:22

some reason by default it loves throwing

play07:24

in a model prefab here which we don't

play07:27

need we're going to go ahead and get rid

play07:28

of that otherwise it's just going to

play07:30

double spawn some controllers on us and

play07:32

we also want to change our teleportation

play07:35

area and make sure that it's going to

play07:37

match the orientation so if we check

play07:39

that then we'll be able to use the

play07:41

thumbstick to rotate the reticle left or

play07:44

right and so we'll face a certain

play07:46

direction once we teleport and if you

play07:48

watched my previous video on XR

play07:50

interaction groups I added one to our

play07:52

left hand but we're going to have to add

play07:54

one to the right hand now since we have

play07:55

all these different interactors and we

play07:57

need to decide who is going to be in

play07:59

charge so they're not overlapping each

play08:01

other and you can see the one for from

play08:03

the left hand that I have here but

play08:05

that's not important we're not playing

play08:06

with that that was last video this one

play08:08

we need to add it to our right hand

play08:09

controller so we're going to start by

play08:10

adding an XR interaction group

play08:13

okay and then I'm going to hit the plus

play08:15

sign a few times and let's see here

play08:18

right now I only have three active ones

play08:21

I do have the rate interactor but I

play08:23

don't want to play with that and have

play08:25

that inner switch with the teleport I'm

play08:26

okay with just the teleport active right

play08:28

now and then I'm going to drag these in

play08:30

and you want to put these in the

play08:32

priority that you want them to override

play08:34

the other ones so teleportation is

play08:37

pretty important I want that first and

play08:39

then let's see I want direct and then

play08:41

poke

play08:43

now another way you could actually

play08:45

organize this so you don't have to worry

play08:47

about which location these are in you

play08:49

could just dictate who overrides who

play08:51

here but since I already have these in

play08:53

the order that I want I'm just going to

play08:54

leave them like that and then we also

play08:56

need to get the XR interaction manager

play08:58

which I have mine up here and then

play09:01

finally for the group name this is going

play09:03

to be for the right hand so you just

play09:04

type in right we are almost done but

play09:06

we're not quite there yet we still need

play09:08

to add an action based controller

play09:10

manager and so this is what's going to

play09:12

tie it all together and you'll see

play09:13

there's a bunch of empty slots here and

play09:15

they're pretty self-explanatory so you

play09:18

know the manipulation interaction group

play09:19

is going to be the one that's already

play09:21

attached here then we have the direct

play09:22

interactor and I'm just going to fill

play09:24

these out really quick

play09:26

now we don't have a ray interactor so

play09:28

I'm just going to leave that as none

play09:29

finally we have teleport mode activate

play09:31

cancel turn snap turn move and UI scroll

play09:35

and since these are all based on the

play09:36

right hand when we click this we're

play09:38

going to be looking for the right hand

play09:39

so let me look up activate

play09:43

teleport mode to activate and then I'm

play09:44

just going to zoom right through all of

play09:47

these

play09:48

and so now that I've zoomed through all

play09:49

these you can see this is all just right

play09:51

hand Locomotion teleport mode activate

play09:53

teleport mode cancel turn snap turn move

play09:57

and UI scroll but we can also turn on

play10:00

smooth motion enabled or we can also

play10:03

turn on smooth turn enabled so instead

play10:05

of doing snap turn that's how you do

play10:07

that but we do have to activate one more

play10:08

thing and so if we come over to our turn

play10:11

under our Locomotion system now I have

play10:14

it set to continuous turn provider but

play10:16

now that we have this other thing here

play10:18

that can regulate that for us we can

play10:21

actually turn both of these on so with

play10:22

continuous move providers activated but

play10:24

I can turn on the snap turn at the same

play10:26

time and then this script right here

play10:28

depending on if I choose to have smooth

play10:30

turned on or off will allow us to do

play10:32

that no personally myself I like Snap

play10:34

turns so I'm gonna just leave this as

play10:36

off and let's boot up and see what we're

play10:38

working with now all right and as you

play10:40

can see I can snap turn to my left and

play10:42

right and then I can also rotate the

play10:44

reticle with my thumbstick and when I

play10:46

let go I teleport and they have it we

play10:49

have a functioning teleporter and with

play10:51

my left hand I'm able to continuously

play10:52

move and I can still grab objects so now

play10:55

we can teleport big shout out to my

play10:58

patreon subscribers thank you for

play10:59

keeping me afloat sorry it's taken so

play11:01

long but I'm happy to be back and I'll

play11:04

see you in the next one bye

play11:06

[Music]

Rate This

5.0 / 5 (0 votes)

Étiquettes Connexes
VR TeleportationUnity TutorialXR InteractionLocomotion SystemVirtual RealityGame DevelopmentController SetupInput ActionsTeleport AnchorUser Experience
Besoin d'un résumé en anglais ?