Getting Started in VR | Joystick Movement | Unreal Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
good day everyone welcome back to the channel and today we are looking at rotation and player movement with your thumb sticks so in previous video we covered teleportation so now i'm gonna actually quickly show you a simplified um method of movement by just using the joysticks for this i created a new pawn i just duplicated the old pawn and removed all the extras that we've gotten in what we've done in previous videos and also moved or removed all the value variables so they clock completely new pawn basically and the only script that's in here is begin play but just sets for um tracking origin so to make this work we actually have to go to the project settings and make some axe mappings so these are the thumbnails that we're going to be needing and you can just create the inputs by clicking on the drop down and because i'm using oculus i will be using our own input for oculus thumb stick controllers so thumb stick x oculus thumb stick y and oculus left hand from stick x okay and the only value you have to change is on the y this is you can change it here to negative one if you want to invert it but uh i don't want to invert it so i'm just going to keep it like that okay so now going back to our joystick movement black controller we are gonna start with the movement so we're gonna call out the thumbstick i'm gonna start with x and fifth there's gonna be a really simple script um that we're gonna be writing but we actually need a class a reference to a class so the class we're gonna need is a floating pawn movement if you don't know about axis this is going to be calling every frame per second and we don't want it to be called every frame per second um because we're not using any values when the axes are completely zeroed out so we're gonna create take the value that's being inputted to double equal and if a double equals to zero we're gonna bring in a boolean branch if it's double equal to zero nothing's gonna happen but if it's not double equal to zero we are going to do a add movement input and to get these values we are going to do a multiplier from the base input value that will be your scale value you can promote this to a variable and you can call variable movement speed okay and we're just going to compile to do a default value of one you can play around with these values yourself to see what's the best input value that you can get the last thing that we're going to be doing is we're going to be grabbing our camera and we need the right vector so get right vector and from the world uh direction we are actually gonna make a vector so make vector we're gonna take the right world vector we gonna split the pins and the only values that we actually mean be needing is for x and for y we're not using the z because z is going straight up and you can implement if it's part of your game but moment i'm not going to implement it because i don't have a way to showcase it okay this is the base script of movement we're gonna actually just bring in the front right y and we're just gonna be copying all of us and do a paste and just hook everything up the only thing that's going to be changing is instead of getting the right vector we are going to get the forward vector expand it and again just for x and for y values okay now that we have finished the movement let's work on rotation i'm going to be showing you snap rotation pretty basic concept we're going to grab the thumb stick the left side on the x-axis and from here we will be doing a double equals with a branch if you double equals zero um then nothing is going to happen for now but if it does not equal zero we are gonna have to see uh if it's turning left or right the two values that i have added is rotation dead zone and rotation angle um just basic floats for dead zone is at point zero two rotation angle is at zero zero um we are going to be using them to see which um direction the player is trying to move at so for these branches we are going to be grabbing the axis value doing a greater man inkwell we're going to feed it into the first branch we're gonna grab the rotation dead zone do a get and added where for the second branch you're also gonna grab the axis value and do a [Music] it's more of an equals i'm going to feed it in there and to get this value we're gonna take the dead zone and we're gonna multiply it by another float and we just can multiply it by negative one to get the direct opposite of the dead zone value so for these branches if you do greater than equal we want to turn by 45 degrees and if you do smaller than equal it's gonna be negative 45 degrees so we're going to take the rotation angle we are going to do a set and this is going to be 45 and another rotation angle to set negative 45. from here we actually want to do a do once the reason why this is important is if you don't do a do once you you're just constantly gonna be snapping around and you're not really going to be stopping until you actually leave a lever and we don't want to add we actually want them to to constant snapping by using the thumb stick and not just holding the thumb stick in and they will be going round and round and round for the reset we are going to grab the false value of a true value from the first branch that we made and also something else that i'll show you later down the line from here we need a set actor transform and the target we're just gonna keep it empty but what we're gonna do is take the transform the new transform we're gonna split it and we're gonna also split the rotation because we need just for bare bone values because we're just gonna be rotating rotating the player on the z-axis not none of our axes okay for the transform um location and scale we are actually just gonna be doing a get actor transform we're going to split it open and we're just going to be grabbing for all values from the location and scale for the transform we are going to do a get actor transform get active rotation we're going to take the y value and we're gonna add it to the angle rotation that we created okay let's quickly test it as you can see i can read around 45 degrees great the last thing that i actually want to show you guys is um a better way to reset the do ones because at the moment only time it resets it is if you basically completely leave a thumb stick to zero out value so we're gonna actually take the branch here and make another branch and it's going to take the true value to reset it and the conditions for the branch is going to be taking the actual value to a greater than and also take the actual value smaller than and we're gonna do a or and basically values what we're going to be putting in here is negative 0.2 0.1 and just the normal 0.1 if you want to take the dead zone and bump it up to a 0.5 you can actually take these values and bump them up to 0.2 and point negative 2. negative 0.2 and you actually have a bit more room uh for the player to keep on rotating without leaving thumb stick completely okay that was rotation and movement if it was educational remember to like and if you want to see more content surrounding unreal engine development in future i'll be covering a lot more than just normal vr so please subscribe and i'll see you all in next video
Info
Channel: Raptor Tech
Views: 515
Rating: undefined out of 5
Keywords: unreal engine, unreal engine 4, unreal, unreal engine vr, unreal engine vr tutorial, unreal engine 4 vr, unreal engine 4 vr tutorial, import to unreal engine, unreal vr getting started, unreal engine 4 vr game tutorial, vr game development in unreal engine 4, unreal engine 4 vr tutorial beginner, learning vr in unreal engine 4, making a game in unreal engine 4, how to make a vr game in unreal engine, unreal vr tutorial, learning unreal engine 4 vr game development, vr movement
Id: xFVc12Cbhmo
Channel Id: undefined
Length: 14min 59sec (899 seconds)
Published: Wed Jan 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.