Simple Interaction System Unreal Engine Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right so to make an interact system the first thing you want to do is create your blueprint interface so right click and go to your blueprint right here Blueprints and then go to blueprint interface and name this BPI interact and then open this up and inside of here on the function we just want to call this function interract just like that and essentially what blueprint interfaces are is they allow multiple blueprints to sort of send messages to each other blueprint interfaces are basically perfect for interact systems and stuff like that so just make sure you compile and save this and we can completely close out of this and now as you can see there's a lot more actors and widgets down here and I can go through each one of these so the BP interactable is just going to be our base interact I've set this up just a little bit it's just going to print string interacted and then the BP destroy is a child class of interactable and whenever you interact with this it's just going to destroy itself and launch is just going to launch it it's going to set this should launch value to True which is going to let this tick go through and add force and just launch it up into the sky these are just simple blueprints I set up to show you how the interact system can work so then the two other ones is the prompt and the HUD The Prompt essentially is press e to interact the reason why this is separated is because I want to hide this whenever we're not actually looking at anything interactable and if I go to the HUD as you can see the Press e to interact is here here but also we have this little dot here as well for the cursor or whatever and if I show you this in game as you can see only the dot is here but once we have the functionality set up on these where we can actually interact with them the Press e to interact will pop up and so yeah basically I just want to show you that it looks like there's a lot here but this stuff literally has nothing in it this is just a text there is a event construct where I just hid the visibility on the prompt just so it's not showing obviously but yeah there's not really much setup on this whatsoever all right so now that we have our interact out of the way we can open up our character and in here this is just where I was creating the HUD right here you just create BP Hud get player controller create a value for the the HUD you just right click promote to variable and then add it to the viewport so typically interact systems use LINE traces they can use overlaps at times but a lot of the times they use LINE traces and so what we are going to do is right click and search for event tick and this will make sense in just a minute while we're using tick and you want to drag off of this and do line Trace by channel right here here all right and so now this next step you want to kind of get this down because it's very useful because it's how you can do a lot of line traces with the character and so basically what it is is to get a line Trace to shoot out of the camera and to have it go where the player is looking you want to drag out your follow camera drag off of this and do get World location and this is the easy part because this is your start position right out the gate then you want to drag off follow camera again and you want to do get forward Vector right there now you want to drag off of this and do multiply and then drag off of get World location right here and do an ADD and then connect this up connect this up and then this multiply down here change this from a vector go down here convert pin to a float and this float is how far your line Trace will actually go from the camera so let's say I want it to about 1,000 just so it's long enough or actually just to be on the safe side for the tutorial purposes I'm going to do about 3,000 but you want to play with this value and get it to the distance that you prefer and so next we can set up the interact or the blueprint interface stuff and so off of this out hit you want to drag out this and break hit results like that and uncollapse it so you have all the stuff and hold down B and left click to get a branch and blocking hit we just want to do a true or false just to see if we actually hit something and next we want to determine if what we hit actually has the interface we created inside it so drag off of hit actor and search for does implement interface and for the interface search for BPI interact right here and sort of like I was saying is say we have a puzzle game and the puzzle pieces you can interact with the puzzle pieces but say you're inside of a room right well you don't want to be able to interact with a wall in the room you only want to be able to interact with puzzle pieces so this is why we have to check if it actually implements the interface or not so hold down B again and then drag this up to there and connect this to the true path and then off of H actor again what you want to do is right click promote this to a variable call it interact actor whatever you prefer and then you drag this over here connect it up to the true and so this is setting our interact actor that we came in contact with and so now what we want to do is make sure we set this value to null so drag out set interact actor whenever it's false for everything so if we don't even hit anything we want to set this interact actor to void or null and if we do not implement the interface in the actor we also want to set it to null as well and so now off the true and false path this is where we control our HUD that I was talking about the visibility of it that's essentially all this tick really does is controls the HUD and we set this value to use when we actually like press e or whatever our interact button is so drag in your HUD right here GI HUD drag off of this and do get and I believe I CAU it where is it at get BP prompt right here and drag off of this and do set visibility like that and on the true side that that means we actually came in contact with something so we want it to be visible and then do set visibility once again and this time set it to Hidden because we did not hit anything or we or we may have hit something but it's not interactable and so now we can compile and save this and so now we can actually set up the interact function so so for the tutorial I'm just going to use the E key just because it's super simple if you were setting this up for an actual project you would want to do the enhanced input which I can do a tutorial on in the future probably next week now that I think about it and so yeah just let me know below if you'd like a enhanced input action tutorial I can get right on to doing that but for now though just I'm just going to use e just for Simplicity so now off of the E press you want to drag your interacting interact actor out and we want to check if this is valid right here and if it is valid then we want to interact we want to call the interact message from our blueprint interface and for the interact actor we want it to obviously be or for the Target we obviously want it to be the interact actor right there and if this is not valid then we don't really want to do anything and see this is this is and once again this is where we're setting this right here this is if it's false or false then there's no intera act actor but if they're both true then we have an interact actor and we can interact with it when we press e and so now if we compile and save this and I believe we could close out of the character but I'm just going to minimize it and now we set up our interactable objects so open up BP interactable and in here you want to go to the class settings I believe and go down here to interface and Implement interface add and you want to search for BPI interact and as you can see we get a little new little section right over here with our interact you want to double click it and it will create a event for you and like I said in the base interact this one I just wanted to print string whenever I interact and since all the other actors are children of this one since we already implemented it here we don't have to go to the class settings and implement the interface on all of them it's already implemented so we can minimize that we go to BP destroy see as you can see it's right here double click it drag to destroy actor compile save minimize go to launch double click it drag it to our Boolean right here compile save and now we should be done all right so testing out the interact system as you can see we're looking at different objects the interact message is not popping up but then we look at the interact objects it pops up and notice how I can interact with it all the way back here I could go all the way back here this is just because of how I set it up with the tutorial you can set the value to like something like 100 and you have to be right on top of it right here the only reason why I can do it so far away again is because of the distance of the line trace and as you can see we can interact with all three of them and whenever our DOT leaves the object message goes away comes back up goes away comes back up and now if we interact with this as you can see interacted in the top left we can spam it this one whenever we press e it should destroy itself and it did and then this one should just fly up in the sky whenever we interact and it did and as you can see I can interact with it again because it's it was still in range but yeah that's just a simple interact system all right so if you found this video useful subscribe for more and as you can see there's a very small percentage of people who actually view the videos who are actually subscribed so so if you find it interesting then once again subscribe for more and I will see you in the next one bye-bye
Info
Channel: The Average Dev
Views: 337
Rating: undefined out of 5
Keywords: simple interaction system unreal engine, how to interact in unreal engine, interaction system unreal engine, ue5 interaction system, interact in unreal engine, ue5 blueprint interfaces, unreal engine blueprint interface, interaction unreal engine, how to interact with actors in unreal engine, ue5 interaction tutorial, unreal engine simple interact, ue5 simple interact tutorial, unreal engine how to make an interaction system, unreal engine interaction tutorial
Id: H2A3gQXwTes
Channel Id: undefined
Length: 13min 7sec (787 seconds)
Published: Sat Feb 17 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.