Doors That Open Away From You- Unreal Engine 4

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

This was really good! I appreciate the speed of your video, there's no need to speed up the video :)

πŸ‘οΈŽ︎ 18 πŸ‘€οΈŽ︎ u/palle97 πŸ“…οΈŽ︎ Dec 17 2019 πŸ—«︎ replies

thx man i might not need it right now but it will probably help me in the future
Edit: nwm this is very helpful and i didnt know it ;)

πŸ‘οΈŽ︎ 4 πŸ‘€οΈŽ︎ u/MapelSiroup πŸ“…οΈŽ︎ Dec 17 2019 πŸ—«︎ replies

Now time to make one where you always bump into the door before realize you have to pull it open.

πŸ‘οΈŽ︎ 4 πŸ‘€οΈŽ︎ u/Lazureus πŸ“…οΈŽ︎ Dec 17 2019 πŸ—«︎ replies

I'm pretty sure there's a door exactly like this in the Content Examples project.

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/BluShine πŸ“…οΈŽ︎ Dec 17 2019 πŸ—«︎ replies

Excellent

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/2HDFloppyDisk πŸ“…οΈŽ︎ Dec 17 2019 πŸ—«︎ replies

Looks great Cob. Love your zelda vids, they've helped me learn more about blueprints.

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/PeanutJellies πŸ“…οΈŽ︎ Dec 17 2019 πŸ—«︎ replies

Just what I was looking for!

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/Bagsy666 πŸ“…οΈŽ︎ Dec 17 2019 πŸ—«︎ replies

It's always great to have more tutorials for unreal.

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/Reus_Irae πŸ“…οΈŽ︎ Dec 17 2019 πŸ—«︎ replies

Well, there is the content examples. But cool anyway

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/deathclonic πŸ“…οΈŽ︎ Dec 17 2019 πŸ—«︎ replies
Captions
hey everyone in this episode we're going to be creating doors that always open away from you so let's go into content let's create a new folder called blueprints go into here create a blueprint class actor and we will call it BP door we can open that up right before we get started on the door let's make a couple changes to our firstpersoncharacter this will also work in the third person character first thing I'm gonna do is disconnect this input action fire so we don't spawn our projectile one we click and then I'm going to go into our capsule component and change the capsule radius to 34 so that we will actually be able to fit through the door alright let's go back into BB door and we're gonna make a scene and replace the scene root with a scene then let's add two static meshes one for the door frame and one for the door itself now if you have the starter content enabled you will be provided with a door frame and a door so we will be using those now we need to drag the door over because the pivot point is on the left so let's change our snap size to 5 and move it over 45 units and the other thing we have to do is set up a collision for the door the starter content door doesn't come with a collision so double click on the static mesh right here and go to collision add box simplified collision and then in here I'm going to scroll down to a gate collision primitives boxes open this one and I'm going to set the X extent to 5 save that and close it now our door will have collision all right let's go into our event graph and we can delete these three we will call a new custom event and it will be called open door now we need to do some math to figure out which side of the door we're on so let's do that now we need to get our scene which is in the direct center of our actor and we want to get our world location and we need to subtract our player location from this point so create a begin play cast to first person character the object will be get player character then you can right click right here and promote variable we will call this player ref now let's get our player ref and we will get the actor location and we can do vector minus vector and plug these in right here this will get us the distance between our two actors then we want to take this output and normalize it the easiest ways of understanding this is it's just converting it to a scale between negative 1 and 1 but we don't want the output to be a vector we want it to be a float and we do that with a dot product now the other side of the dot product is going to be the forward vector of our scene and we will plug that in to give you a little demonstration of what's happening in the tick we can just print a string and we will plug that in for the duration I'm just going to plug this into Delta seconds so it doesn't flutter screen and let's drag a door out into our world and hit play now if you look in the upper left it's getting covered up by the shift f12 that will fade we have this point eight and it gets lower as we get closer and if we get to the other side it goes to negative 0.5 and it will slowly ever increase the get close to one as we back up and one on the other side so we use this to decide which side of the door we were on so let's go back into pp door and we can delete this and they tick now an open door we need to first ask if the door is closed so let's make a boolean and we will call it is door closed and plug in to our condition by default we want to set this to true because the door is closed if this is true we want to set the door close to false because we are opening it and this is also where we want to define our dot product as a variable so you can right click here promote to variable and we will call this dot product and plug it in right here after this we want to call it time line which will open our door for us so we can right click and create a time line and we will call this open door tl for time line and plug this into the play now double-click under timeline in this length here this is gonna be how long it takes to open and close the door I'm going to set it to half a second and then we want to add a float track and we will call this alpha' right click and add two keys the first one will time will be 0 and value will be 0 the second one time will be 0.5 or however long it takes to open your door and the value will be 1 click these two icons to fill the screen because it's like both of them right click and choose Auto this will give us a smoother opening and closing now on the update we want to sent this doors rotation so we looked right off the store and set relative rotation and plug that into the update and we only want to rotate it on the z-axis and we can do the end we can separate these by getting a make rotator now we only want to rotate on the z-axis because when we do it rotates how the door rotates set this back to 0 2 by default and let's go back to our event graph and in this Z we want to get aehlert or sense for linear interpolate and plug the alpha into the Alpha the a will be 0 and the B will either be 90 degrees or negative 90 degrees depending on which side of the door we're standing on so we want to get a select from there and the condition is going to be if the dot product is greater than or equal to zero I'm doing greater than or equal to so if in the rare chance you get exactly on 0 it will know what to do so we'll plug that in to pick a and on a we want to set this to 90 and on B we want to set this to negative 90 unfinished we want to ask if the door is now closed so it's off this direction and get a switch on a time line direction because we only want to set this when we are reversing our time line speaking or reversing we want to plug this false into reverse so if our door is open and we click we want to reverse this time line to close the door once that's finished off of backwards we will set is door close to true and we should be almost good to go the door is all set up now we just have to actually be able to open it because at the moment we have no way to interact with it so if we go into our first visit character we can create an input left mouse button so when we click it's going to create a line trace from our camera to a certain amount of units away from our camera directly in front of us when trace by channel is what we will be doing let's right-click and actually let's just pull in the first person camera or the third person camera if you're using the third person template and we would get the world location and the forward vector the world location will be our start value and our end value will be our forward vector multiplied by a float this float will be how far away we can reach how long the line will be from our camera to this many units in front of us I like 500 as a good default and we will add these together and put that into the end location now out of out hit we want to break this and open it up and here in hit actor we will cast to BP door so if we hit the BP door we will continue in this execution and if we don't it'll go in this one so as BP door we want to call the event open door and that will automatically connect this for you so we can compile save and go here so let's test this out let's click on the door and it opens away for us let's click on it again and it closes now let's go to the other side click and it opens away from us still and we can close it again now let's open it go to the other side and we can still close it normally we could also close and open the door before it opens and closes all the way and won't have any issues such as doing things like this and just switching around we've eliminated all bugs so this will always work in terms of opening away from you all right I hope you found this lesson useful please consider subscribing to get more content like this and also join us in a journey of remaking the entire breath of the wild game in Unreal Engine 4 and I will hope to see you there
Info
Channel: Cobb Dev
Views: 15,675
Rating: undefined out of 5
Keywords: Unreal engine, Realistic, System, Movement, Toggle, Level, Tutorial, Ue4, Video, Game, Program, Code, Cobblestone, Develop, Development Cobb, Dev, Bionic, Leaf, Mannequin, Legend of Zelda, LOZ, Breath of the Wild, BOTW, Let’s Create, Developer, arcade, udemy, fps, fix, bug, door, open, away, dot, product, interact, doors
Id: hZHj5CtonQA
Channel Id: undefined
Length: 10min 7sec (607 seconds)
Published: Mon Dec 16 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.