How to make pressable BUTTON for VR (unreal engine vr tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello there's our fancy and welcome in this tutorial where you can learn how to make a pressable button for your VR game let's look at how it will look like okay so first of all let's make sure that you notice this professional I made button best on the market you can get better VR button anyway if you press it the doors open and if you press it again the doors will close again you can connect it to whatever functionality in your game you just want alright then let's get started I am in basic VR template that you can have when you start on in Jinan VR mode and this additional stuff as stable and swart are here from my previous project on how to make a sport if you want if you want to see the tutorial you can link in the description but that's not why we are here we are here to make a push button or just a button so let's go to blueprints content or you know what we will actually do it just in content I was created here in new blue brain blueprint class and actor because we need to create some button and that's how we will call our mesh ok and let's add ok let's rearrange it a little bit and add here component and that would be mesh and let's do static mesh compile and let's use key loop it's a little bit too big so let's get it down to 0.1 or 0.2 maybe and it's always good to test it right in VR so if we put it just here that seems about right size ok scale it down and that rename it to body if you are using our custom mesh and want to have some specific button which you probably do feel free to do so the only thing you change here is the static mesh of course okay then let's copied it duplicate it and call it button ok put it a little bit up and scale it ok compile and we probably need to change some material to do we can use whatever so I will use M base material which that is something that you should have in your project as well if you just start or you can use whatever you want so if you look at it it seems like we have a really really simple button okay let's put it here on the table on the table and let's do some programming so another thing to add this collision box collision and make sure that it's attached to button and put it a little bit more up thanks give it down so it's really online here and it's probably better to have it at the same size as your button okay compile and adhere event begin overlap now from here we need to cast to object that will be touching that phone in our case it will be our mesh our virtual reality hand which is in virtual reality BP blueprints and there is BP motion controller so we need to cast to it cast to BP motion controller and connect object to other actor next thing we want to do is to animate it so that should be simply by taking this button and move it so take it from here and add here a move component to and connect it let's say that I want to have it in time of one second and now we need to set target location and target rotation so from our button it could be same as we s it is connected to component we will get a relative transform and split it split structure pain let that rotation connect rotation and the location we will do just small an adjustment and add here - vector - vector and everything will be same except we will take it - ten or maybe five on z-axis five core five vector coordinates on z-axis and to test it out we will take our and begin playing and connect it here just so we know if it actually works okay click here and click on simulate it seems like it worked just fine so we can use it here wonderful and test it in VR if everything works ok now I mean game right in front of that button so I will simply put my hand on it and you can see that it works like a charm it doesn't go back and it actually goes much lower that's something we need to fix right now first thing we need to push is to make sure that once it is pushed it won't be pushed again and again and again so let's go to back to our button and we will create a variable simple boolean and let's call it is pressed ok and simply before that we will add here a branch and make sure that you don't have it in true but in false and connect here is pressed and after false first thing we'll do is to set is oh I've actually show you a little trick that I'm using take this is pressed and put it here and pass Conte and press control like that it will jump just to set which is what you need and we to set it to true which means that once this will start overlap you will put your hand in there it will ask if it is pressed and if it if it will be pressed it won't do anything but if it won't be pressed it will do this pressing and just to make sure that it will you can press it again let's go to end of your code take your is pressed control again and set it to disabled again ok but we need to also add it to your previous coordinates so we will simply take all this control C move that further ahead and after completely touch put here a GUI let's say one second and we need to change few things before it will be Paris ever again ok we need to change this note so it's in minus five and we need to set it to plus so vector plus vector and set it to plus five so it will be on the same coordinates as it's actually starved it okay compile and put it simply here move and then it will be capable of pressing it again okay compile and see if it works again in front of the button so what go here and put your hand into it works it waits and it needs up again you can change timing just as you need and let's try it again and it works like a charm okay now you can make a game of a pushing and pressing buttons but if I showed you only this it would be actually a really boring tutorial so let's make a door or something that we can do with this so for that we will create another blueprint and actor call it door open it and add here a mesh again static mesh preferably use your own machines but I'm not going to waste my time on that and primarily not your time so let's put our static mesh here now a two-sided static mesh again for cube and scale it only on one axis which means see I believe how it's why probably but that doesn't matter okay let's put that here and you can already see that it doesn't really do what I want so let's rotate it you can have it side by side or if you have two monitors that's even better okay again and it was nothing which you probably have set it to a ninety degrees and put it up oh no actually you need to put it up here and scale it hey it's no fancy here just a quick info you are learning how to press a button and you haven't even press the like button I'm serious what would your mother say to that go press the like button let's continue a tutorial and it actually is rotated completely differently than I would like to now it works and I decided I want this door to be opened as soon as I press this button so I push this button so for dead plaits okay let's scale this up and they go to event graph and we will create here custom event so let's right-click and we will add here event so custom event add custom event and let's call it opening I'm sure that's not how you write opening that's better I didn't need to google it don't look at me like that okay so let's go here and from here on we will again move component you right now you are probably only using casting and moving components but that's just fine I can connect it to component from here get all occasion and oh you know what it will actually take both because I'm not really sure what it will do with rotation so get a relative transform and split structure pin connected to rotation and location set to minus vector minus vector move this a little bit down and I believe it will be probably y-axis and let's try minus 50 that's probably a really a lot so let's try like then okay and again best way to test it is just to go to event begin by make sure to do at it over time unless you want it's a really fast and see what it does ok simulate okay that didn't really move so let's try it let's try to edit it a little bit let's add here make sure that it's only after opening them I have just you guys I did it on other monitor sorry about that with that I have just changed return value location to plus and set it to boost plus 300 and target relative location I will try to make sure that I won't do it again and let's close it and connect it to our button so edit button and the door right here before our overtime let's put here get our actor of location and get our actor of class and set that to no door move everything else and let's set it to a little bit shorter because otherwise we don't want to wait unless until it will be all closed we actually need to get actor of class so get actor of class not all actors and that will be set to door and from here on we can use opening now it should work ok cut it from here and see if it works well it won't work because we need to actually press that button so we are preview and try to press that button ok turn it and you can see the doors moved wonderful but if I press it now it moves even more which is something that you can need to fix but that again that should be really simple in our door blueprint let's go after opening we will add here a flip-flop this is my favorite note because it just sounds fun to say it flip-flop ok move it and put that flip-flop here after you at flip-flop you can simply take all this and control-c control-v again and i think you need to do is to change this note to - vector - lecture and set it to - free hundred so it should get to its original state and connect it to move ok now back in VR let's test it out so i have press the button the doors moves and let's press it again and it moves back congratulation guys good job good job everyone if you are interested in that swab tutorial let me quickly show you you will be able to make such a smart or not made but how to put it in any engine even able to cut stuff okay that's everything for this tutorial I hope that you learned something if you did write in comments what you are okay this is stupid you don't have to make a button I know I know anyway write in comments what the next vr tutorial would you like to see or what kind of game that video would you like to see that's everything from me and join the discord like subscribes all this funny stuff you know how it works here on YouTube in end of YouTube anyway I don't know I'm kind of distracting right now so fun say out
Info
Channel: Sir_Fansi Gamedev
Views: 5,961
Rating: undefined out of 5
Keywords: unreal engine vr button, How to make VR button, how to make a vr game in unreal engine, unreal engine 4 vr game tutorial, unreal engine 4 vr tutorial, unreal engine 4 vr tutorial beginner, unreal engine vr, unreal engine vr game tutorial, unreal engine vr tutorial oculus, unreal vr, unreal vr tutorial, Unreal engine VR tutorial, vr button tutorial, vr button ue4, ue4 vr button press, unreal vr button, ue4 vr, unreal engine vr tutorial, ue4 vr tutorial, unreal engine 4 vr
Id: q2oyK8FYxOo
Channel Id: undefined
Length: 13min 39sec (819 seconds)
Published: Thu Apr 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.