Let's learn how to link A VR head-mounted display device
With a phone camera
And a motion source
That tracks the position of the VR controller in real-time
Called Oculus Touch
Once the equipment tracking setup is complete
Let's practice receiving input values
Such as press, touch, and axis of the VR controller
When VR equipment is installed
Checking the log displayed on the monitor is difficult
So, we will use the test render component
To output the controller's input value
Directly on the world
Creating a New Level
Well, since this map we did last time was a test map
We will now create an actual map to make
Select New Level in the file
To create a New Level
The New Level will be based on the Basic level
Let's select the Basic Level as the template
And click the Create button to run it
There's probably a bug right now
Where the border here between heaven and earth is a little bit black right now
In the case of the VR template
If you look on the right here
There will be an Exponential Height Fog
If you select Exponential Height Fog
And look at the bottom of the details section
There is a line called Fog in Scattering Color
So, the shape of the Fog InScattering Color section is
Now black
To make it a color similar to the sky
Let's press the dropper mark and then select
A color of the sky
I'll try to use a darker blue if possible
It feels a little too bright
So I'll try making it a little darker
I'm going to process it a little bit darker like this
Then press the save button
And right-click here to select New Folder
Select New Folder
With the name Maps
Create a folder, and name it
VRMainMap
VRMainMap and save
To save the level
Knowing which game mode is applied
to each new level is important
So, in the content folder, Add, New Folder
Create a new folder, and name it
Blueprints
Right-click in the Blueprint folder
And select Blueprint Class
To create a new Blueprint class
Since we will create a game mode base
We will designate the game mode base class
As the parent class
Let's name it
BP_VRGameModeBase
VRGameModeBase
Next, right-click once more
And create another Blueprint class
This time, we will inherit the phone class
That can be used as a player phone
BP_HunetVRPlayer
We will name it like this
HunetVRPlayer
Now, first, double-click on the VR game mode base you created earlier
To open it
In the Details panel on the right
We will set the Default Pawn Class
To the BP_HunetVRPlayer
So that it will be the default player
Compile and save
Go to Project Settings
At Maps and Modes
The default game mode
Change the BP_VRGameModeBase
We just created
Please check that the Default Pawn Class is
BPHunetPlayer
Here, both Editor StartUp Map and Game Default Map
Will be changed into VR Main Map
The VR main map we just created
Creating a VR Player Pawn
Open BP_HunetVRPlayer again
In the case of player pawn
It will have a scene route by default
Next, acting as our eye
We'll attach a camera component
Camera
Click the Add button
Search for the camera
And then add camera component
In the case of the camera
It has to serve as our field of view
We'll place the screen right in the center here
Next, after the camera component
We will attach two motion controller components
That act as controllers
I will put one on my left hand and one on my right hand
In the component panel, click the Add button
And if you look at the bottom
You will see a motion controller
If you look here, it's called a motion controller
If you're having trouble finding something, search for motion here
And you'll see motion controller
So, add a motion controller
Let's name the first one
LeftMotionController
Add one more motion controller
With a name motion
RightMotionController
Attach with LeftMotionController
And the Right will also be set to default and attached
So that the camera, left motion, and right motion controllers are
All independent
So that it is not someone else's child relationship but the same relationship
I will attach them separately
As children of the default root and direct children like this
The right motion controller
And left motion controller is
Now in the center
There is no one playing a role right now
So now, I will attach mesh data to
All three so that
The headset mark can be displayed at the hand
And camera positions
So, for the first camera, select the Add button
Static Mesh
And attach a static mesh to it
With the name HMD Mesh
Head Mount Display, it is a device worn on the head
We will attach the mesh for the head equipment
As a child component of the camera like this
Next, at the bottom of the details panel
In the static mesh section
If you search for HMD
You will find something called Generic HMD
So, if you assign a Generic HMD here
Like this
The headset-shaped mesh
will be created
Next, on the LeftMotionController side
Add - Skeletal Mesh
We will attach a Skeletal Mesh
I'll give it the name LeftHand here
We will do the same Add Skeletal Mesh on the right side
With the name Right Hand
I will add child components
Now, we're going to attach a hand-shaped mesh to it
First, select the LeftHand
In the DTS panel on the right
If you look at the Skeletal Mesh Asset
There will be SKM_MannyXR_Left
And SKM_MannyXR_Right at the bottom
Since it is left hand, select left
For the right hand
Select SKM_MannyXR_Right
And attach the right hand like this
If you look now, the Right Motion Controller
If you move the parent's Right Motion Controller
The child, Right Hand will also move
If you move the Right Hand Motion Controller to the right
This is the right hand
If you move the Left Motion Controller
Like this to the left
This is the Right Hand Controller
The location isn't that important right now
As for the current position, I arbitrarily placed it
At +50 and -50
But it doesn't matter if it's at 0 or 0 anyway
When we use the headset
These motion controllers are
Automatically adjusted to the position of the equipment
We are using
Position and rotation are automatically adjusted
So you don't have to worry too much about that
For now, I just put it aside for a moment
To distinguish between the right hand and the left hand
Next, for tracking
Which part do you want to track now
With the Left Hand Motion Controller selected
If you look at the bottom
you will see a tab called Motion Controller
If the motion source is set to the left
It follows the left arm
It is correct that the Left Motion Controller follows the left hand
However, in the case of a Right Motion Controller
You have to follow your right hand
I'll change the motion source of the Motion Controller
From left to right
If you look at the motion source here, there are various things like
Left grip, aim, and metal capel
VR equipment has
Not only hand-controlled controllers
But also, elbow trackers that track the elbows
Knee trackers mounted on the knees
Waist trackers mounted on the waist, etc.
There are all kinds of devices for tracking various parts of the joint
There are even gloves
Track the thumb, index finger, middle finger, ring finger
And even little finger
But basically, all we need to do is
Track the light and motion source
Just specify Left for the left hand and Light for the right
as the motion source
In the case of cameras
The motion source will not be specified separately
And the head will be selected later
From the event graph
First, let’s go into the event Graph tab
Right-click
On the Event Graph tab
And select Is HMD Head
First, check whether the mounted display is
enabled and whether head-mounted equipment
can be used
First, check whether the head mount device is
Connected to the PC
So, if
The Head Mount Display Enabled is True
Search for Set Tracking Origin
And add
The Set Tracking Origin node
This is based on which side
The headset equipment will be positioned
If you have a pawn, there are things like whether you want to do it
From the center of the pawn or the bottom
But these standards vary depending on the head mount equipment
Among the head mount devices is
The Oculus Quest type that we are currently using
And then there is also the Vive made by HTC
There are things like Cardboard made by Google
and other things
For various devices, such as Samsung's Gear VR
The height reference point differs for each skin point
So you need to match it to the device
As standard
Oculus Quest and HTC Vive
Probably come with stages
So, I will change it to a stage
And put it in stage form
Next, do compile, and save
Then, let's return to the map
And check if the tracking works properly
Please turn on VR and let us raise our hands one at a time
Now, the camera seems to move well if I move my head
My hands move well, but there is one strange thing
Now, the right and left hands are aligned
But the direction of the hand does not match the direction of the actual controller
So, let's rotate this shape a bit to fit
The position of the controller
Go back to the Hunet VR Player Pawn
On the left handle in the viewport
Click the rotation tool
And then rotate it 90 degrees to the right side
And then 90 degrees
To this side
Then, my right hand
Left to 90 degrees
And 90 degrees in this direction
So that my hand is standing like this
Usually, when we take control, the standard is
Set like this
First, compile and save
Then see if the hand appears at this angle
Do not rotate the motion controller
All you have to do is set the rotation of the motion controller to 0, 0, 0, 0
And rotate the hand skeletal mesh
Underneath it like this
Let’s press play to confirm
I raised my hand this time
But I think I raised it too much
At this point, my hand is
A little higher than my hand right now
Let me lower it a little bit
Since my hand was too high
I will lower it slightly now
Should we just try lowering it by about 40 degrees?
Now that we raise our hands, it seems to be somewhat similar
To the direction in which we actually point our hands
So, place the hand at an angle like this
Now we're going to press the button
The fingers still don't move like
The VR templates we tested before
We'll have to process animations for that later
But for now, we'll try to get some input
As to whether a key was pressed and display it as a log
If we wear a headset like we are now
When leaving a log with a print string
It is not easy to check it
I can't keep putting the headset on and taking it off
So what we're going to do is
We're going to put some 3D text up here that can display something
On the top of the hand like this, on the top of the wrist on both sides
Now, go back to the BP Hunet VR Player Pawn
And this time
Add it as a child component of the Left Motion Controller
If you look down, you will find something called a Text Render
Text Render
Make the Text Render component a child of Left Motion
With the name Left Log
We will give it a text component
Add to the right hand
And attach a component called Text Render
I'll name it Right Log
Now, you will see text written at the positions
of your right and left hands, respectively
I'll just label it as the child of left hand and right hand
Because the hands are going together anyway
In the first Left Log, I will set it to 0, 0, 0
And then rotate it
So it is in the same direction as the hand
I think it should be around -90, -90
After initializing the Right Log on the right hand
It should be -90, -90
So this should be +90, not -90
This side should also be +90
90, 0, and -90
Because the direction on the right is different
The letters and text appear backward at the back
So, I think we need to set it like this
So that our gaze is in the right direction
Next, I will raise
The position of the Left Log a little bit
By about -20
Set it to 0, 0, 0
I'll do the same with the Right Log
Raising it about 20 degrees upwards
Also, the text in the Left Log is
Currently written to
The right based on this pivot
So it is aligned to the left
But now, to align the font
In the center around the hand
If you look at the bottom here
The horizontal alignment of the font is currently set to the left
So you can set it to the center
If you set the vertical alignment to the text center like this
The sentence will pivot, and the letters will be input
To align with the exact center of the text
Even in the case of the text color
I will try to use a slightly yellow color
That is more noticeable than white
Should I go with a slightly brighter color?
I'll mark it with a bright yellow color so it stands out
I'm going to set the right hand the same way
I'll mark horizontal as the center and vertical as the text center
And then the render color will be yellow
Which is completely bright yellow
So that both are displayed like this
Once you compile and save
The text above your hand will
Look like this in the playlist
The text seems a bit large right now
So I'll try reducing the font a little
First, starting from the left log
Here is the font size
It's called world size
It's currently set to 26, but I think 26 is a little too big
So I'll reduce it to about 15
I'll also try reducing the font for the Right Log to around 15
Compile, save
Get User Input
Now, it's our turn to receive actual input
When receiving input
You first need a file related to the input in the content draw
First, let's create a folder to create
The input mapping context and input action files
Click the Add button in the content folder
And select New Folder
Let me create a folder with the name Inputs
Then, go into this Inputs folder
Right-click
And create an Input Mapping Context in the input
We'll call this IMC_HunetInputMappings
With the name Hunet Input Mappings
I will create an input mapping context
Next, I'll right-click the mouse
And add an input action to the input
We will create one with the name IA_Index Trigger_Left
This happens when you press a button on your left hand
called an index trigger
Then, right-click the mouse
and select Input Action
This time, we will call it IA_ThumbstickAxis_Left
Thumbstick axis left, index trigger left
On one more input
Including IA_Hand Trigger_Left
We will test 3 input actions
If you look at the thumbstick on the controller
The text here is a little blurry
But this is what we call
The thumbstick now
I have this thumbstick as a 2D marker
So you can move the pad up, down, left, and right
The index trigger is this button where your index finger touches
When you click this button
Index Trigger Button is clicked
When you press this button
The index trigger button is pressed
So what I wanted to create as an input action now was
To create a thumbstick button, an index trigger
And a hand trigger
Please remember that there is also
A separate button called XY
Now, in the case of hand triggers
it would be digital
Because you just press it and release it
Now, in the case of index triggers
we will also check with a digital bool
Save
In the case of the thumbstick axis
instead of the digital bool
the thumbstick could be moved up, down, left, and right
So, we will change it to vector 2D form like this
Axis 2D
then save
and assign this
to the input mapping context
Double-click the input mapping context file to open it
In the mappings, click the plus button to add one
First, add an IA_index trigger
left button
Another addition is
the IA_hand trigger
We will allocate a left file
I'll add another
IA_thumbstick axis
In the case of the first index trigger
if you look here, it says Oculus Touch
Oculus Touch The Quest controller provided by Oculus is
named Oculus Touch
Among Oculus Touch, there are Horizontal Left
Left, and Right
Among these, there will be a trigger on the left
There is not just one trigger
but a trigger axis and trigger touch, this is index trigger
Among them, if we are not sure
we will assign the trigger first
As with the hand trigger
a button will be assigned to the inside of the hand trigger
but in Oculus Touch
the hand trigger is called a grip
So, the grip has a grip button
and a grip axis
So, if we're not sure
we'll just choose a grip
Next, IA_Thumbstick Axis Left
on the left side of Oculus Touch
there are various thumbstick axis
and you can set them separately
to receive only the X-axis value or the Y-axis value
There is also a 2D axis that can receive
all the 2D XY coordinates we wanted
Also, there are buttons under it for touch, up
down, left, and right
If you are unsure
we will start with the 2D axis first
I'll save it later
And then I'll come back to the BP Hunet VR Player Pawn
Now, go to the Event Graph tab here
In the event graph tab
let’s register the input mapping context
to the system
Now, first, GetPlayerController
Related to the input
the player controller class handles everything
Controller 0 in GetPlayerController is
the controller we are operating
GetLocal from controller 0
If you search for GetLocal
you will find a function called GetEnhancedInputLocalPlayerSubsystem
GetEnhancedInputLocalPlayerSubsystem
The name is a bit long so it might be difficult to remember
Just type input local and you will be able to find it
Now, if you search for Add Mapping Context here
you will find a node called Add Mapping Context
Connect the execution pin to Add Mapping Context
Next, as the mapping context file
we will specify the IMC Hunet Input Mappings file we created earlier
You can set the priority to 0
Okay, so the mapping is done
We registered the input mapping context file we created
as a subsystem of enhanced input
We should log in to see if
what we entered is correct
Now, the first thing we did was
IA_Index Trigger_Left
So, with the event
we will run the IA_Index Trigger_Left node
It is initially folded
but this will unfold all the actions
By pressing the button
when we press it
when it is started
add the set text node
of this left log
and connect the execution pin to the start like this
To connect the text here
let's run the Make Literal Text node
And here
output the Index Trigger Pressed
Let’s try output it like this
Then, when it is released
and completed
it will do a set text
Then
I'll duplicate this using Ctrl D
In addition, it is inputted
when completed
Here
we will compile and save
the Index Trigger released
Similarly
add an event node
to the left
IA_Hand Trigger event file
Likewise, this time set text
in the left log
Let me add a set text
and connect it to Started
Next
After Make Text
Add Make Literal Text
And here, enter the word
Hand Trigger Pressed
and connect it like this so that it is output to the log
Also, duplicate set text by pressing Ctrl D
When you release the Complete button
when you release button
duplicate the Make Literal text again
and instead of Pressed
connect
the Released value
Lastly
add IA_ThumbstickAxis_Left
as an event
Likewise, in the left log
do set text
In the case of the thumbstick
it will be receiving in the form of an Axis or 2D Axis vector
so each time you press the trigger
you will receive that value for the entire time you press it
So, the actual value will be
the value of this action
We will directly connect this value to the value
and output
the vector 2D value
Also, I duplicated the set texts once more
I did not connect them here either
Target here
Didn't I do it above? I did
Connect the target
and when you finally release your hand
When you release your hand
so that this value is output like this
we will input it once
The rest was entered like this
Then actually
press the compile and save buttons
If you come to the main screen
and look at the bottom
you will see the VR Template
If you look inside the VR template
you will see a folder called Input if you look here
There is something called PMI_VR Template
Double-click this file to open the settings window
Here is Player Mappable
Speaking of context
there are arrays of input mapping context files
to be registered in VR
What we created is not here now
So, click the plus button here
to add one more
In addition
we will assign the IMC_Hunet
and input mapping files
we created here like this
First, save it
and then press play
to test it in real life
Next, look at your left hand
with your left index finger
when you press the index trigger button
A button called Index Trigger Pressed
will appear like this
When you release your hand, the message “Index Trigger Released”
will be displayed
Shall we try a hand trigger?
If you press the button with your middle finger
the hand trigger is pressed
When you release it, it will say hand trigger released
Then, if you move the thumbstick
up or down and left or right with your thumb
if you move it up correctly
Y will almost always point to a value of 1
X will point to a value of 0, close to 0
If you move it down, X will be close to 0
and Y will be close to -1
X is a value close to -1 when turned to the left
If you move X to the right, X will be close to +1
In this way, we can mark our hands
Now, if you just set this up
and create only IA files and input action files
you can output the same thing with your right hand
Now, if you look at the input
and the input mapping context earlier
in the case of the index trigger
there are three types of left index triggers in Oculus Touch
axis, touch, and trigger
There are three kinds
So, in the case of the index trigger button
if you just select the index trigger
the value will come out as a true false
If you use the index trigger axis
the input level of the button is 0
when it is not pressed, and 1 is when it is pressed all the way
and the value will be between 0 and 1
Now, when it comes to touch
when your finger touches the button before pressing the button
input can be received through True False
So, let's change it one by one
and print the value
First, let's change it to Axis
Try changing the left trigger to the axis
and then save
On the index trigger left side
this time, instead of printing the text directly
change it to the trigger axis
Save it
Next, we will change the value
of the index trigger left
to Floats instead of Bool
so that this key can actually enter the axis value
Save
Next, the action value of the index trigger was changed to true
Let's take this value and print it out
each time
it is pressed and released
Then, this axis is
the value of pressing the button
pressing the button halfway, pressing it about a third of the way
pressing it all the way, and so on to continuously check the situation
I'll take off the started
and connect the trigger
The converted value will continue to be output
as long as the button is pressed
After compiling and saving it
I will output it
Let's just look at the left hand first
When you press the index trigger with index finger
the number will go up
If you press it up, it becomes 1
and when you start rereleasing it, the number decreases
and you can see that it becomes 0 when you release it completely
This means you can directly get the value between 0 and 1
such as how much the button was pressed
This time, the index trigger will be changed
from Axis 1 to digital again
Change it back to Bool type
After saving
in the input mapping context
I used the Oculus Touch
and tried the trigger and trigger axis this time
It is said that true false is displayed whether the button is pressed or not pressed
the value of the degree of pressing is displayed as a value from 0 to 142
and the trigger touch is not a button pressed
but a true false is displayed when the button is touched
I'll change it to this
change it to touch, save it
and test it out
First, I will output the value
directly using True False here
You can use text
but I'll try outputting it as True False
Since it is True False, there is no need for a trigger
and you can reconnect to Started
If you compile, save
and play again
you can now see that instead of pressing the button
if you just lightly touch the button
Touch, false, touch, false
If you release it, false, if you touch it, true
You can see that it is displayed like this
Now, the same goes for hand triggers
Also for the hand trigger
In the case of hand triggers and grips, there is a grip and a grip axis
and the axis is returned
as a float value between 0 and 1
This is True False
and there is no touch in the case of the grip
You can think of it as not being able to tell the extent
of the touch of the button
In the case of thumbstick buttons, X-Axis
Only the left and right values of the X-axis are
brought when the thumbstick is tilted from side to side
only the value is brought separately
when the X value is moved up and down
or both XYs are brought in
Vector 2D form with 2D axis
By the way, I think we can find out about it here
There are buttons and touch
Touch means putting your finger on the thumbstick and taking it off
It's the same as a trigger
However, I didn't know that
the thumbstick also had a button
The thumbstick button is pressed
like a button
So when you want to use it in a way that you press it like a button
you can use the thumbstick button
Of course, the value of this is true or false
Then there is the up and down left right
Up, down, left, right is different from the X-axis
And Y-axis mentioned earlier
When raised upward, once when lowered
Only once when lowered to the left goes to right
So at one axis
if one way X-axis is left and right
when you try to receive input
separately for left or right
you can register
multiple events like this
You won't often use it this much
but you can occasionally use it
So, like a button
Like a cross button, like a pad button on a joypad
You can receive input like a button
I think you should know like that
The right hand is almost identical to the left
The ones we haven't tried yet are the XY
and menu buttons
which only require clicking
There is only true false when pressing and not pressing
and in the case of XY, press and release are used
In other words, press means pressing and releasing
Touching is done by placing your finger on the button
and releasing it rather than pressing it
You can try these out
yourself and
find out what these buttons are and what they mean
take a log of all of these things
and practice by recording them
all once to see
how the actual action value comes out
The right hand is just the opposite of the left hand
so that you can implement the same for the right hand without difficulty
I'll leave it at that for this time
Next time, now that we can receive this input device
we will try moving the player
using this input
Well, thank you for taking the time to listen to the lecture
Thank you for your effort
I will summarize what I learned in this lesson
First, we confirmed that
each button can receive various inputs
such as press, touch, and axis
and practiced outputting various input values ​​to the screen
In particular, the thumbstick could receive input
separately for each X-axis or Y-axis
and the XY-axis
Second, since each manufacturer has different standards
for the camera height settings of HMD devices
you must wear the headset
and change the settings
to check the height setting
Thirdly, while wearing a VR headset
I tried using the text render component
to check the development log
The text render component has
the advantage of being able to output text directly to the world
and because it is in the form of a component
its size and position can be freely adjusted
Creating a New Level Ready for development Create a new level in Unreal Editor by pressing [File] - [New Level]
Once you've named your new level, save it to your Maps folder Create a new folder with the name “Blueprints” in Content Drawer
Create a new Blueprint class file that inherits the Pawn class and set a name for it
Create a new Blueprint class file that inherits the GameModeBase class and set its name
Double-click the file to open the settings window and specify the file as the Default Pawn Class in the Details panel
Open the Project Settings window and select the Maps & Modes tab Specifying the Default GameMode item as a created file
Specify the Editor Startup Map and Game Default Map items to the corresponding files
Creating a VR Player Pawn Setting up VR Player Pawn Double-click the created file to open the settings window and press [+Add] - [Camera] component
[+Add] - Select the [MotionController] component and add "LeftMotionController" and add with two names: “RightMotionController”
Add a Static Mesh component as a child component of Camera Component and set its name
With the component selected, set the Static Mesh property of the Details panel to GenericHMD
MotionController allows you to specify which device is tracking Go to the [Event BeginPlay] node in the Event Graph panel to track the position of the HMD device
Connect the [Set Tracking Origin] node and set the Origin property value to Stage
Use the [Is Head Mounted Display Enabled] node to check whether the HMD device is connected
Get user input Setting up user input Create a new folder named “Inputs” in the content drawer
Select [+Add] - [Input] - [Input Action] to create 3 Input Action files
Select [+Add] - [Input] - [Input Mapping Context] and create a file
Double-click the file to open the input settings window and assign the previously created Input Action files to the Mappings item
Designate the Oculus Touch button to receive input for each Input Action. Play and confirm that text is output every time you press the bound input key
Convert the input value to Touch (bool) or Axis1D (float) and perform an input value output test
The End