2023 Unity VR Basics– Continuous Movement

Fist Full of Shrimp
18 Aug 202310:18

Summary

TLDRThis tutorial focuses on setting up continuous movement in XR development using Unity's XR Interaction Toolkit. The instructor starts by disabling hand tracking to conserve battery and simplifies the XR origin setup. They introduce the Locomotion System component to coordinate movement, explaining the Continuous Move Provider for smooth locomotion and the Dynamic Move Provider for varied directional control. Turning mechanics are covered with both Continuous and Snap Turn Providers, highlighting customization options. The necessity of a Character Controller for boundary setting and gravity application is emphasized, along with a new Character Controller Driver for seamless head movement tracking. The tutorial concludes with a functional movement and turning system, ready for further development.

Takeaways

  • 🎮 The tutorial focuses on setting up movement in XR using the XR Interaction Toolkit.
  • 🔋 The presenter turned off hand tracking on their Oculus Quest to conserve battery and also disabled the XR hands from the previous tutorial.
  • 👐 The tutorial reverts to using left and right hand controllers with animations instead of the controller model from the previous session.
  • 🚶‍♂️ A Locomotion System is introduced as the coordinator for movement between the XR origin and move providers.
  • 🔄 The Continuous Move Provider is added to enable movement in the direction the user is looking, with options to enable strafing and flying.
  • 🔧 The tutorial explains how to set up gravity application modes and forward source based on user preferences.
  • 🎯 It's recommended to use either the left or right hand for movement to avoid conflicts, with the left hand being a common default in VR games.
  • 🔄 The Dynamic Move Provider is introduced as an alternative to the Continuous Move Provider, allowing for different movement preferences for each hand.
  • 🛑 The tutorial advises caution when using the Continuous Move Provider due to potential motion sickness and suggests the Snap Turn Provider for a more accessible alternative.
  • 🏃‍♂️ A Character Controller is added to prevent the XR origin from passing through objects and to enable gravity effects.
  • 🔄 The Character Controller Driver is used to synchronize the character controller's height with the user's head movements for a more natural experience.

Q & A

  • Why did the speaker turn off hand tracking on their Oculus Quest?

    -The speaker turned off hand tracking on their Oculus Quest because it was draining the battery a lot.

  • What is the purpose of the Locomotion system in the XR interaction toolkit?

    -The Locomotion system is responsible for coordinating between the XR origin and all the move providers to manage movement within the XR environment.

  • What is a Continuous Move Provider and how is it added in the script?

    -A Continuous Move Provider is a component that allows for smooth movement in the XR environment. It is added by creating an empty object, naming it 'move', and then adding the Continuous Move Provider component.

  • What are the options for gravity application in the Continuous Move Provider?

    -There are two modes for gravity application: 'Immediately' which applies gravity as soon as movement stops, and 'On Movement' which delays gravity until the user moves again.

  • Why might the speaker prefer using the left hand for movement in VR games?

    -The speaker finds that the left hand has become the default for movement in VR games, which is why they prefer to use it with the Continuous Move Provider.

  • What is the function of the Character Controller and how is it added?

    -The Character Controller provides a boundary to prevent the user from moving through objects and allows for the application of gravity. It is added by selecting the XR origin and adding the Character Controller component.

  • What is the Character Controller Driver and how does it solve the issue of the character controller not moving with the XR origin?

    -The Character Controller Driver is a component that synchronizes the movement of the character controller with the XR origin. It is added to the XR origin and linked with the appropriate Locomotion provider.

  • What are the two types of turn providers mentioned in the script and how do they differ?

    -The two types of turn providers are Continuous Turn Provider and Snap Turn Provider. The Continuous Turn Provider allows for smooth turning, while the Snap Turn Provider enables quick, discrete turns, which can help reduce motion sickness.

  • Why might the speaker recommend deactivating one of the move providers if using both is an option?

    -The speaker recommends deactivating one of the move providers to avoid conflicts and ensure a smoother user experience, as having both active might cause unexpected behavior.

  • What is the significance of the Radius setting in the Character Controller and how does it affect the user experience?

    -The Radius setting in the Character Controller determines the size of the collider, which affects how close the user can get to objects without clipping through them. Adjusting the radius can improve the user's interaction with the environment.

Outlines

00:00

🛠️ Setting Up the XR Interaction Toolkit

The paragraph discusses the setup process for the XR Interaction Toolkit, focusing on changes from previous tutorials. The speaker turns off hand tracking on their Oculus Quest to conserve battery and decides to disable the XR hands from the previous tutorial. They revert the controllers to the left and right hand configurations, ensuring the correct hand has the animator and controller components. The speaker then introduces the concept of a Locomotion system, which coordinates movement between the XR origin and move providers. They create an empty child object named 'Locomotion system' and add the Locomotion system component, linking it to the XR origin. The paragraph concludes with the addition of a continuous move provider, which is configured with options for strafing, flying, and gravity application. The forward source for movement is set to the main camera, and the left hand is chosen as the default for movement actions.

05:01

🕹️ Configuring Movement and Turning in VR

This paragraph delves into the specifics of configuring movement and turning in a VR environment. The speaker starts by setting up the dynamic move provider, which allows for different movement preferences for each hand. They experiment with head-relative and hand-relative movement directions for the left and right hands, respectively. After testing, the speaker decides to deactivate the dynamic move provider in favor of the continuous move provider for its simplicity. The paragraph then moves on to turning mechanics, introducing both continuous turn and snap turn providers. The speaker configures the continuous turn provider with the right hand for turning, adjusting the turn speed for a more comfortable experience. They also discuss the snap turn provider as an alternative to prevent motion sickness, setting up the snap turn with specific inputs for quick directional changes. The speaker emphasizes the importance of a character controller to prevent characters from passing through objects and to apply gravity correctly. They add a character controller to the XR origin, adjusting its radius and center to fit the character model and ensure it interacts properly with the environment.

10:03

🎬 Wrapping Up the Tutorial and Acknowledging Support

The final paragraph is a conclusion to the tutorial, where the speaker thanks the viewers for watching and encourages them to like and subscribe for more content. They express gratitude to their Patreon subscribers, emphasizing that their support is crucial for the continuation of their work. The speaker signs off with a friendly 'bye', indicating the end of the tutorial.

Mindmap

Keywords

💡XR Interaction Toolkit

The XR Interaction Toolkit is a set of tools and components designed to facilitate the creation of interactive experiences in extended reality (XR) environments. In the video, the toolkit is used to set up movement and interaction within a virtual scene, emphasizing its importance in developing immersive XR applications.

💡Continuous Movement

Continuous movement refers to the smooth and uninterrupted motion of an object or character within a virtual environment. The video discusses implementing continuous movement using the XR Interaction Toolkit, which is crucial for creating a natural and engaging user experience in XR applications.

💡Locomotion System

The Locomotion System is a component in XR development that coordinates the movement of the XR origin and all move providers. It is central to the video's tutorial, as it is responsible for managing how users navigate and interact with the virtual environment.

💡Move Providers

Move providers are elements within the Locomotion System that determine how control is exerted over the XR origin's movement. The video explains how to set up a continuous move provider, which allows for the character's movement based on user inputs, such as thumbstick directions.

💡Dynamic Move Provider

The Dynamic Move Provider is an alternative to the Continuous Move Provider, offering different movement preferences for each hand. It is mentioned in the video as a way to customize movement based on the orientation of the user's hands, allowing for unique interaction styles within the XR environment.

💡Character Controller

A Character Controller is a component that adds physical boundaries to the user's movement within the virtual space, preventing them from passing through objects. In the video, adding a Character Controller is shown as a necessary step to ensure realistic interactions with the environment, such as preventing the user from walking through tables.

💡Snap Turn Provider

The Snap Turn Provider is a component that allows for abrupt, 90-degree or 180-degree turns in the virtual environment. It is discussed as an alternative to the Continuous Turn Provider, potentially reducing motion sickness and making the game more accessible to a wider audience.

💡Gravity Application

Gravity Application in the context of the video refers to how gravity is applied to the user's movement within the virtual environment. The tutorial explains two modes: 'Immediately' and 'On Movement', which determine when gravity effects are applied to the user's movement, such as when climbing or falling.

💡Hand Tracking

Hand Tracking is a feature in XR devices that allows for the detection and interpretation of hand movements. The video mentions turning off hand tracking on the Oculus Quest to conserve battery, highlighting the importance of balancing functionality with device performance.

💡Oculus Quest

The Oculus Quest is a standalone virtual reality headset mentioned in the video. It is used as an example of a device where the developer chose to disable hand tracking to prevent excessive battery drain, indicating the practical considerations involved in XR development.

💡XR Origin

The XR Origin is a reference point in the virtual environment that serves as the anchor for user movement and interaction. The video explains how to set up the Locomotion System and other components in relation to the XR Origin, emphasizing its role in coordinating user experiences within the XR space.

Highlights

Introduction to using the XR Interaction Toolkit for movement in VR.

Recommendation to disable hand tracking on Oculus Quest to save battery life.

Instructions to turn off XR hands from the previous tutorial for non-hand tracking games.

Switching controllers back to left and right hand configurations.

Explanation of the Locomotion system's role in coordinating movement in XR.

Adding a Locomotion system component to the XR origin.

Enabling strafe and fly options in the Continuous Move Provider for more movement freedom.

Setting gravity application modes for realistic movement.

Choosing the forward source for movement direction based on camera or controller orientation.

Selecting the left hand as the default for movement in VR games.

Demonstration of character movement using the left hand controller.

Discussion on the need for a Character Controller to handle collisions and apply gravity.

Adding a Character Controller component to the XR origin for boundary and gravity management.

Adjusting the Character Controller's radius to prevent clipping through objects.

Raising the Character Controller to avoid falling through the ground.

Introduction of the Character Controller Driver to synchronize head movement with the character.

Setting up the Continuous Turn Provider for smooth turning movements.

Customizing turn speed and adding snap turn functionality for quick direction changes.

Comparison between continuous and snap turn providers for accessibility and motion sickness considerations.

Completion of the tutorial with a fully functional movement and turning system in VR.

Transcripts

play00:00

let's get moving using the XR

play00:01

interaction toolkit and continuous

play00:03

movement a few things have changed from

play00:06

the previous tutorials so you should

play00:07

definitely pay attention to this one

play00:08

booting back into the scene you'll see

play00:10

nothing's really changed here but

play00:13

there's a few things I want to go over

play00:14

and change from the previous tutorial

play00:16

the first thing I'll mention is I did

play00:17

turn off hand tracking on my Oculus

play00:19

Quest I noticed it was draining my

play00:21

battery a lot so if you're not using

play00:22

that for your game I would advise you do

play00:24

the same and since I've turned that off

play00:26

for my XR origin I'm also just going to

play00:28

turn off the XR hands that we did in the

play00:30

previous tutorial the last thing I'm

play00:32

going to change is I'm going to go over

play00:33

to my controllers here and if you

play00:35

remember from the previous tutorial I

play00:36

changed this to the controller instead I

play00:39

want it to go back to our left and right

play00:40

hand that we had before and you'll see

play00:42

we have two same named ones here but

play00:44

one's just going to be a model the other

play00:45

one is going to have the animator and

play00:47

all the controllers and that's the one

play00:49

we want so I'm going to select this I'm

play00:51

going to select the one that had all the

play00:53

animations and controllers and then do

play00:54

the same for the right hand

play00:56

all right and now we're ready to get

play00:58

moving the first thing we'll need is a

play01:00

Locomotion system and this is what's

play01:02

going to be responsible for coordinating

play01:04

between our Locomotion or moving our XR

play01:07

origin and all the move providers and

play01:10

that's how they've structured this so to

play01:12

do that I'm going to collect this I'm

play01:14

going to add an empty child I'm going to

play01:16

name it Locomotion system

play01:18

with that in place I'm going to add

play01:19

component Locomotion system

play01:21

and then it's asking for the XR origin

play01:23

as simple as that there we go now we

play01:26

can't move with just that we need

play01:28

providers so as I said before this

play01:30

coordinates with move providers and then

play01:33

this determines what has control over

play01:36

the XR origin so the first thing we'll

play01:37

want to add is a continuous move

play01:40

provider to add that I'm just going to

play01:41

right click this create empty and I'm

play01:43

going to name this move and then I'm

play01:45

going to look up continuous move

play01:47

provider and you're looking for the

play01:49

action base now you'll see here we have

play01:51

some fun things to fill out so first is

play01:53

The Locomotion system I'll drag that

play01:55

here next we can enable strafe so that

play01:58

is being able to move left and right

play02:00

diagonally but also forward we can

play02:03

enable fly which is actually pretty cool

play02:05

you can uh just kind of look around and

play02:08

fly around use gravity is there and then

play02:11

it has two modes for Gravity application

play02:14

so it's either attempting to move so say

play02:16

you're climbing a ladder and let go

play02:18

until you move you won't apply gravity

play02:21

so I find immediately to be more

play02:24

realistic the forward Source this is

play02:26

going to determine what is our forward

play02:28

Source how it says oh you're going to

play02:31

move forward in this direction when you

play02:33

press the thumbstick and so I find the

play02:34

main camera to make the most sense for

play02:36

that next we have our left hand move

play02:38

action and right hand move action so you

play02:41

want to in my opinion pick one or the

play02:43

other you don't necessarily want both

play02:45

your thumb sticks to be able to move you

play02:47

and I find that the left hand seems to

play02:50

have become the default when it comes to

play02:52

VR games and so to do that we're just

play02:54

going to look up move left hand

play02:56

Locomotion now again you could do this

play02:59

for the right hand you would just add

play03:00

this here if you wanted to be right hand

play03:02

based

play03:04

there we go and we could select that

play03:05

there previously let me open this up

play03:08

really quick you'll see here for our

play03:09

locomotions and inputs they actually

play03:11

used to not have anything for the right

play03:13

hand they just just assumed that you

play03:15

would use it for the left hand but now

play03:17

they filled it out so you don't have to

play03:18

stress about that anymore which is nice

play03:20

again I said I don't really like the

play03:22

right hand as the move for the

play03:24

continuous move provider so I'm just

play03:26

going to mark this off and if we boot it

play03:27

up the scene you can see I can move with

play03:29

my left hand and based on where I'm

play03:31

looking and pressing forward it moves in

play03:33

that direction so there you go now I

play03:36

will say at this stage the gravity will

play03:38

not work if I walked off the cliff it

play03:40

didn't work because we do need a

play03:43

character controller and I'm going to

play03:44

add that a little later towards the end

play03:46

of the video but for now I want to

play03:48

continue on and talk about the dynamic

play03:50

move provider so the dynamic mode

play03:52

provider is just a different form of

play03:55

continuous move provider and how it

play03:57

works is you could actually do some

play04:00

interesting things with this essentially

play04:02

what this bad boy does is is it allows

play04:05

you to determine what you want as a

play04:07

preference for each hand you'll see down

play04:10

here it has a left hand move Direction

play04:13

and a right hand move Direction and so

play04:14

we could have one be set to the Head

play04:16

relative so like the continuous move

play04:19

provider but then we could have the

play04:20

other one be hand relative So based on

play04:22

the right hand's orientation that's what

play04:25

forward would be I mean it's it's

play04:27

interesting I don't know what you would

play04:29

use it for but here it is and this is

play04:31

how you set it up so again a Locomotion

play04:33

system you could put it here forward

play04:35

Source we want it to be the main camera

play04:37

and then you would add your references

play04:40

head transform again would be the main

play04:43

camera

play04:44

and then you want the left and right

play04:45

controller

play04:47

and let's see yeah I'll have the left

play04:50

hand be the head relative and then I'll

play04:53

have the right hand be hand relative and

play04:55

let's boot up and see what we got and

play04:57

one thing I should do before I boot it

play04:58

up is just make sure I turn this off so

play05:01

it's not fighting between the two

play05:02

scripts but right let me start it up now

play05:04

you can see that when I start to move

play05:07

with my left thumbstick I move in the

play05:10

direction of my headset but when I use

play05:13

my right thumbstick and press forward it

play05:15

moves in the direction of where my right

play05:17

hand is pointed and yeah that's how that

play05:19

works now my personal preference is just

play05:22

to use the continuous move provider so

play05:24

I'm going to go ahead and deactivate the

play05:26

dynamic move provider and I'm just gonna

play05:27

go with the continuous move provider

play05:29

next up we need to learn how to turn so

play05:32

to do that we can do a continuous turn

play05:34

provider or a snap turn provider to add

play05:37

that in I'm just going to right click

play05:38

here and I'm going to add an empty

play05:40

object and I'm going to call it turn

play05:41

starting off I'm going to go with the

play05:43

continuous move provider

play05:45

and then we are just going to drag in

play05:48

The Locomotion system here oh my bad

play05:51

that made the continuous move provider

play05:53

so I did that before yeah just make sure

play05:55

you don't do that it's very easy to do

play05:57

all right there we go all right and then

play05:59

next we need to add in the turn and I

play06:01

found that if you're moving with the

play06:03

left hand you want to turn with the

play06:06

right hand and vice versa if we were

play06:08

moving with our right hand it makes a

play06:09

little more sense to turn with the left

play06:11

hand so since I am moving with the left

play06:13

hand I am going to go ahead and look up

play06:16

turn here and you want the right hand

play06:18

turn and so now if we boot up the scene

play06:21

you'll see that I'm able to turn to my

play06:23

right and my left coming back to the

play06:25

editor if you thought that was turning a

play06:27

little too slow you can change the turn

play06:29

speed here and then one word of caution

play06:31

when using the continuous move provider

play06:33

it has been known to cause motion

play06:35

sickness so the snap turn provider might

play06:38

make your game a little more accessible

play06:40

to others so I'm going to go ahead and

play06:41

deactivate that and I'm going to add a

play06:43

Content or snap turn provider again we

play06:47

add our Locomotion system here you can

play06:49

change the turn amount here this

play06:51

debounce time just kind of allows for a

play06:54

little wait time between each snap turn

play06:56

so it just doesn't happen in quick

play06:58

succession we also have a turnaround one

play07:01

right here and that just allows for 180

play07:03

so if your player pulled all the way

play07:05

back on the thumbstick that would allow

play07:07

them to do a 180 turn and then if we

play07:09

were doing the reference again since I'm

play07:11

using the left controller I want the

play07:14

right snap turn here and this actually

play07:16

does have its own input and so instead

play07:19

of just turn you use the right hand

play07:20

Locomotion snap turn in just like that

play07:23

when I hit the right or left I'm able to

play07:25

snap turn right and left just like that

play07:28

boom so we are now able to turn and move

play07:31

are we done no so the problem is we are

play07:35

able to run through this table and also

play07:37

gravity is not working and that's

play07:39

because we don't have a character

play07:41

controller so the character controller

play07:43

is going to add a boundary for us so we

play07:45

don't run in into things or through

play07:47

things and then it will also allow us to

play07:49

apply gravity to something so to add

play07:52

that it's as easy as going to the XR

play07:54

origin then we're going to add component

play07:55

character controller and you'll see here

play07:57

we have a few attributes we can play

play07:59

with starting off we have the slope

play08:01

limit so this if we were going up a

play08:04

slanted Hill would determine how steep

play08:06

of a slope we can go up now one big one

play08:08

that we should change right here is

play08:10

probably the radius so as you can see

play08:12

here in the scene it's a pretty chunky

play08:14

boy right there and so to reduce that

play08:16

I'm going to change this radius to maybe

play08:19

0.2 and feel free to experiment and see

play08:22

what feels right in your game here and

play08:24

so if we were able to start up the scene

play08:26

now we should be able to run into this

play08:28

table but before we do that we should

play08:31

probably also raise this character

play08:32

controller a little higher and I mean

play08:35

you could do that by raising your XR

play08:36

origin but I don't think that's too wise

play08:38

I think it's a little better to move the

play08:40

center here and so what that'll do is if

play08:42

we did not move that up we would just

play08:44

fall through the ground now as you can

play08:47

see that I am running forward I am

play08:50

running into this table and not going

play08:52

through it but there is a bit of a

play08:54

problem again so when I go to stand up

play08:57

and move you'll see the character

play08:59

controller is not moving with it

play09:01

so let's fix that now luckily for us we

play09:04

used to have to code this in ourselves

play09:06

in the previous tutorial but Unity has

play09:08

added something for us and it is the

play09:11

character Controller driver so I'm just

play09:13

going to add that and it's going to ask

play09:14

for a Locomotion provider and this is

play09:16

going to be based off of what your move

play09:18

provider is so I'm just going to drag

play09:20

that here and you'll remember I'm using

play09:23

the continuous move provider instead of

play09:25

the dynamic move provider so if you're

play09:28

using the dynamic move provider I would

play09:30

just get rid of this one just use one or

play09:32

the other honestly and then it is asking

play09:34

what our Min and Max height is so that

play09:36

would determine the Min and Max height

play09:38

of our character controller so let's

play09:40

start up the scene and see what we're

play09:42

working with now so

play09:43

now when I move my head mounted display

play09:46

I goes up it goes down left right it

play09:49

doesn't matter where I move this will

play09:51

now track and follow so that takes care

play09:53

of a major issue for us and yeah that is

play09:56

it that's continuous movement and

play09:58

turning that'll do it oh

play10:02

if you found this tutorial moving

play10:04

consider liking and subscribing and to

play10:07

my patreon subscribers I really can't do

play10:09

this without you thank you so much hey

play10:11

I'll see you all in the next one bye

play10:14

foreign foreign

Rate This

5.0 / 5 (0 votes)

相关标签
VR DevelopmentXR InteractionContinuous MovementHand TrackingUnity TutorialLocomotion SystemCharacter ControllerMotion SicknessVR ControlsGame Development
您是否需要英文摘要?