Let's Build A VR Button Grid Puzzle in Unreal Engine! #unrealengine5 #gamedev #tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everybody currently in the GD XR toolkit I decided to buy it as an early Christmas present to myself it is a beautiful starting file for uh VR development in Unreal Engine so I decided to treat myself but today we're going to be going over this which I just made it is one of those old school puzzles where you have to make all of the lights green which currently would be like uh press down there maybe up here okay I solved it I knew I could eventually and we get a sound effect whenever it's solved uh and today we're going to be going over how to make this so stay tuned and uh while I've got you please like comment and subscribe before the video it really really helps we're on our way to a th which I'm very excited for so I'll see you at the tutorial all right so that was my version right here but we're going to make a new version for the actual tutorial and I'm just going to put it right on this wall and the the cool part is is that you're only going to need three Blueprints and one of them is not really a blueprint it's an interface so first let's go ahead and right click open up blueprint class we'll make it an actor we're just going to call this BP Tut for tutorial button all right and we're going to make another blueprint class actor we're going to go with BP Tut brain now I'm going to have a lot of puzzles in my game so there's going to be a lot of brains that are handling how the information's being figured out but for this tutorial we'll just leave it as bptt brain and bptt button and last but not least we need to come into our rightclick menu go to Blueprints and select interface and we will keep it simple bi for blueprint interface uncore Tut let's open up that first cuz that's the easiest one to set up all we have to do is right up here new function wants to know the name we are going to call it on off compile save done literally don't have to do anything else there now we can go into our let's do the button next open up our button and we're going to add uh for the sake of this tutorial I made like custom buttons but you can literally use anything so we're going to do it with a cylinder okay we call this button cuz it's the button uh we'll scale this down by locking it putting it 0 2 and then we'll unlock it and on the Z we'll put it 0.1 just so it's a I don't know it's a button all right for the sake of VR we're going to have to let the button know that it can interact with the player so we're going to go down to the Collision we're going to set it to custom and then under object type we're going to set to VR interactable I believe this is the same on the usual VR template but it's definitely the case if you're using the GDX R template this will make it that we can actually do things with the button that's basically all we need for the buttons so let's go ahead to our event graph and actually before we even do that let's go ahead and click our BP Tut button go to our class settings and then our interfaces we can just go ahead and add our interface that we made which was Biore Tut yay okay so now we have our interface right here on off at the beginning we would like to know whether or not the button is on or off because when the puzzle is set up it's going to start with different buttons on and different buttons off so in order to get that we're going to go to our variable and we're going to make a new bullion that's just going to be called on or off okay we'll drag that out bring that into here we're just going to get the answer to that we're also going to make that awake since each button on the panel is an instance of this blueprint so that way we can edit which one start on and which one start off anyway we're just going to feed that value into a branch go ahead and attach that to event begin play so that way it knows you know what it should look like at the beginning we'll drag off of that we'll do a set material of the button right I completely utterly forgot about this we're actually also going to make materials so we're going to come in here make a new material do mty Tut on okay and then we can just open that up press three hold down three and click sorry hold down three and click drag this onto the missive color and then set this uh this is on so we'll do green and it should show up there perfect it's green yay that all looks correct to me all right and then we can hit apply save now that one's done we can go back into our Shelf and we can just duplicate this call this one off open up off and we'll just change the color to Red cuz Red's an off color it means off apply save and then we can close that one as well so now back in our BP tutorial button blueprint we can set the material to that mty tutou on for true because on is true we can just copy this and paste it drag the false down to the the new material and we'll make this empty uh Tut off so now no matter what the button is here I can even show you we'll compile and save we'll go back to the demo room we'll grab our button I'm going to rotate it since I'm putting it on a wall and we can real simply just hold down alt drag it out drag it out and now we have a 3X3 grid of buttons and we can go through and I can be like this one's on the this one's on uh this one's on sure and now if I go ahead and just simulate you'll see that the ones that I selected are green the ones that I did not select are red perfect that's exactly what we want now is as good as the time as any to set up all the different kinds of variables that we're going to need so let's go ahead and add a new variable and we're going to call this one uh button left okay I'm going to grab the name and copy it just so that way I can do this a little bit quicker and we're we're going to set that as a BP Tut button object reference and we're also going to make that awake oh we can duplicate awesome even better so we're just going to hit contrl D on this then and we're going to set this to right and I'm just going to speed through this part because it's literally left right up and down that's all that we need okay and then we need one more variable which is going to be our reference to our brain so we'll duplicate this one more time cuz that's just makes it a little bit easier we'll do button brain or let's just do brain we'll search for our BP Tutt brain right here object reference and we want that to be awake as well because again we're going to be specifying what brain we're using in order to solve the puzzle all right and now we just basically have to plug everything in so we're going to go up to our button right our cylinder add an on component begin overlap uh from there we'll do a do once then all we're going to do is grab one of our buttons just get a reference to it and then drag off and type on sloff and we're going to find the buyou onoff message uh we're going to plug that in now we want it to affect again the button to the top bottom left and right so we're going to duplicate this four times and then just replace each of these with the ones that we haven't set up yet so here's right get button get button get button and we'll just plug those back into the target cuz all of these are buttons so we know that all of these have the target is by on them now for the sake of this puzzle we also want to tell it to change our onoff state for the button that we're currently on to the opposite of what it currently is so we're going to get on or off we're going to plug that into a not statement and that's going to go into the honor off bullion set so we're just telling it to actually do that uh and then we're going to take that into a branch where the condition is the current state of the honor off bullion and we're just going to do the same exact thing that we did at the beginning so we can honestly just come over here grab these again and paste those back in true makes it green false makes it red okay we're just about there now we're going to grab our brain bring that in get brain and we're going to message the on slof for by and we're going do that regardless of which one of these fires we're going to do a delay because if you don't do a delay whenever the button gets pressed it'll press it like a million times really quickly so you want it to just press once and the delay of 2 seconds perfectly fine and then from there we're just going to drag this back and reset the button real quick just in case if you missed any parts here this is the full string that we're building and these are all the variables that we're using as well as the interface that we have implemented we're not out of the woods yet for what the button needs to do because we also need to make it that buttons are affected by other buttons whenever their adjacent buttons get pressed I just said buttons too many times let's say ducks instead no that's not so we're going to make an event for on and off which is actually right here convenient so now whenever something triggers the on and off event that's being refer referencing our button it's going to fire off this event what event do we want to fire off basically the same thing that we just did but singular so basically everything except for the messaging that we sent out the first time we're going to grab except for the delay we're just going to come down to that event and we're going to fire this drag boom and there you go that is everything the button needs we can compile and save so then let's really well let's start working on the brain so first off let's just grab the brain bring it in above everyone else right just so we know that it's on in the map already and let's open up the blueprint the brain doesn't need anything as far as Graphics because it's just there to kind of mitigate the data and try to figure out whether or not we've succeeded so we'll go over to the event graph and this one's going to be a lot faster because it's just one line basically we can delete all the other events that they started out with because we're going to use our own custom event but first we have to go to our class settings and we have to make sure that we have our interface on this brain so bi Tut there it is so now we have our onoff interface which is exactly what we want make sure that you compile and Save uh after you've added your interface otherwise you won't be able to get this event onof so now whenever the buttons send a message over to the brain it's going to fire this event off first thing we're going to do though is delay because if we don't add a delay here uh there's an exploit where people can win this puzzle without actually completing it correctly SW add our delay it doesn't have to be long at all we're just going to make it 0.1 and then we're going to get all actors All actors of class and that class is going to be BP Tut button okay so now we have how many buttons we have ooh and this is a really good point to remember that we need two variables on this one we're going to need here we'll call it a button count and we're going to set that to an integer because it's a solid number it's not like we have half of a button somewhere uh we'll duplicate this and we're going to call this one buttons active which is going to figure out how many buttons are currently on so step one's going to be figuring out out how many buttons we have so we'll get or we'll grab the out actors and we'll get length and we'll go down to button count and we'll set the button count using that number just plug that in right here we're also going to set our buttons active to Zero by setting it to zero every single time this event gets called before we check to see if all of the buttons are on then we can roll out accidentally adding more buttons than there are that are on does that make sense I hope that makes sense so anyway set button active to zero and we're just going to plug that in we're not going to attach these make sure these are not attached don't be like me uh and then we're just going to drag off here and we're going to for each Loop and we're going to grab our actor array of our buttons and we're going to plug that in here and the cool thing about four each Loops is that we can actually now mess with variables inside of each of these objects individually so we'll drag off our array element type on or off make sure we're on BP Tut button and we will get on or off so this is just going to tell us whether or not the button has an on state or an off State on that variable then we go to Branch set that as our condition and if it's true so we'll increment integer one to our buttons active so we'll get our buttons active active plug it into here and from there we're going to have another branch and the condition of this branch is going to be that we're going to also take our button count so we're going to get our button count and we're going to check to see if both of these numbers are equal so is button active equal to button count if it is the condition is true which means that the puzzle is done all of them are on so now you can literally plug anything into true does this open up a door if it does then you're going to send a message to the door saying open does this cause a sound to play does this cause an animation to start whatever you want it to do from this point forward the rest is all up to you and so we're going to compile and save so now we've taken care of all the coding we should have to do in blueprints for the game that just leaves setting up all of the buttons in the actual game itself the reason why this is such a cool setup is right now we have this you know 3x3 grid of buttons but you could scale it to 50 by 5050 100 by 100 something ridiculous 10 by 10 would probably be the max that I would want to go just for the sake of your players it doesn't matter how many buttons you bring in or what you set them to the puzzle will automatically update itself to work perfectly so let's get it set up all we have to do is go in and make sure that the okay so see this button it doesn't have a button on its left so we don't have to do anything it does have a button on its right so we'll select and we'll grab that button it does not have a button above it but it does have button down so we'll select the button below it and then obviously there's the brain so we'll select the brain that's it like I'll do one more just to show you how easy it is middle button this does have a button left okay so button left uh this does have a button right okay so button right uh this does not have a button above it cuz we're still in the top row so we leave that one blank button down we just select the button below it and then brain well it has a brain so I'm going to go ahead and fill in the blank for all of the buttons that we have currently in this puzzle and then uh we'll be wrapping it up okay that should do it now naturally once you have this set up you want to go in and you want to test it cuz we want to make sure it's working always test what you make okay and then all that that leaves is that we have to test it out so let's go over and give it a go all right I set this up to be an extra easy one for mean just for the sake of testing so boop boop and final thank you so much for watching I hope this tutorial has helped don't forget to subscribe as it really does help out the channel and I'll see you in the next video bye for [Music] now
Info
Channel: VirtualRook
Views: 543
Rating: undefined out of 5
Keywords:
Id: HhsHr3pMoyQ
Channel Id: undefined
Length: 15min 58sec (958 seconds)
Published: Thu Dec 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.