Creating a TV/Screen that plays a video (with sound) | Unreal Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everybody welcome back to another youtube tutorial my name is damian today we'll be taking a look on adding textures to materials which actually play video files now what's great about this is it actually can play audio as well so in this example you can actually hear my voice reverberating around the scene right now which is super cool plus you can also make it work with distance so how far you walk away from the texture it sounds a bit different it's really cool concept so without further ado let's get into the video so here we have a basic scene in the first person blueprint template um you can see here i actually made a crt model um very low polyum uh but it's it's just a good testing it's just for testing purposes okay don't don't hate me because of my modeling work anyway uh something special about this is that the screen part of this is a different material while the rest of the frame is another material that's actually very important because you want the screen to be a singular own material uh if you don't have a screen or crt like this don't worry you can project this texture onto a plane a cube you can project it onto anything that's the great part of this anyway the first thing we're gonna have to do is we're gonna have to import the video now here i have a video it's video to test this its name now i could go in and drag this in but that is not a good idea because of the way unreal engine actually works so if you copy it directly from any other folder then a specific folder then it will actually not include it with the final package the build so that means if it isn't in the certain unreal engine folder it won't actually be shown to the player so what is that certain unreal engine folder we actually have to create so you have to go to your content browser and in your content folder you want to right click and create a new folder before the name should be movies now it should be specifically with an upper m uppercase m it should be spelled exactly like this now if i go ahead and go to my unreal engine projects that's in this pc document documents unreal engine projects so unreal projects then i want to go to the current project which is television and then i want to go to the content folder and then to the movies folder we created now you want to go and go to your video file just want to go drag that over here but it's important to uh not necessarily move it you might want to hold ctrl and while you're dragging over so you copied it over awesome now you can close the videos for a folder but you shouldn't close this movies folder because if i go into unreal engine and open movies you'll see well the video file isn't there it's because um we still have to link it so the way you link it is you just go ahead drag this over there and if i go here we'll see video to test yeah now it's there and now if i open it you'll see uh this file path shows no error if we just dragged it over it would show an error so this is why we've created the movies folder so we actually let the player see the video now we actually have to create a media player as well so we have to go to our content browser right click go to media media player and this additional assets to create and link to the media player you want to take this video output media texture asset now this media player will just go and name it video to test you want to enter now you'll see it created another full uh file which is called a video to test media player underscore video and it's a media texture how this works is this video is actually being played by the media player which sends it over to the texture so it could be applied to material so let's set this up first thing you want to do is you want to go to your video to test media player now by default it actually doesn't have any media but in the bottom left you'll see all the videos in your project and so if i just go double click on this hi everybody well paul's and hit save now this is the singular video file you could create playlist and set that up but that's out of the scope of this video just working with singular videos here so if you selected this double click and the showing up here you could just hit save again you can just close that up perfect now if i go to the video to test media texture you'll see now it actually displays here you also see here at media media player this is the media player so if you didn't actually tick the texture option this is how you can still link it up so that's awesome but now we actually have to make the texture or the video play with sound so let's go to our content browser and go to the content folder right click open blueprint class and we're going to create a new actor we'll name this bp tv now you can name it anything it doesn't necessarily even have to be a television you can make normal screens or stuff like that but in this case i'm making a television so double click that and the first one i'm going to do it's going to add a static mesh the static mesh will be the tv i quickly modeled uh yeah now you also want to add another component so if you so if you actually want audio you just want to get a media sound so if you actually want audio you want this media sound component this will actually be the fin that plays the sound of the video i'm going to drag this out to the front while we're here you can go to the right side and actually set a few settings here so allow spatialization yes uh override attenuation now you can actually um change the settings of this now um here this volume you can actually change the inner radius so where the volume is about max and then the falloff distance but you can also set up stuff like occlusion which means that if the player connects isn't in the line of the audio he can't yet so if he's behind the wall he can't really hear that well uh so you just adjust around with the settings there's a lot and i'm not really gonna get into it because this video would be way too long so compile and save we're gonna go to our event graph now i'm gonna put the play media at beginplay you can put on anything you want so first thing you want to do is add new variable this will be media player and the variable type that will be a media player object types media player object reference i just want to drag that out and get it and now we're going to compile and save this now this media player here you can go ahead and set this already so you can go uh there to test media player but the best way to handle this is actually to go here to media player variable and click on this half closed eye or this closed line click on it now what happens is in the editor you can actually set up each individual tv to display a different media player which means you don't have to make multiple blueprints you can have a singular blueprint which is customizable very handy so as media player we're just going to go ahead and play not play you want to use open source now this you just want to hook up the execution but now this media source we're actually going to go ahead and promote it to the video to a variable why did i save earlier anyway if you just want to go to this media source variable again just want to click open the i so it's a public variable compile and save now this is cool and all uh this means now that if we set up these variables and we'll actually play the video but there's still not gonna be any sound so we're gonna have to take this media sound drag it out and actually uh set media [Music] player so hook up the execution pen and the new media player should be this media player so you can just get that and boom that means uh this code is very reusable so uh each tv can display a different fin by default that's already super cool now um if i go ahead and try to play this so this is the fake tv it's just a mesh alert so we're just going to drag in our bb tv now if i go ahead and actually try to play this you'll see uh nothing goes up right that's weird right that's shouldn't there be something going on well the thing is uh there still isn't a media texture so the fan actually displays it that's why we set up the two material fin right the screen and material so you just want to go to your movies and the best or the easiest way to do that would just be to drag on to that but the problem is because it's a bp you can't really do that anymore so you just want to go create a new material and this will be m underscore video to test yeah matt okay so when it says now if you open that up you just want to go to the base color drag off that or create a new texture sample now the texture texture will use for texture sample will be our video to test media player video now you could just save that and now it's gonna compile now i'm actually going to show you how to avoid a lot of compiling while we're setting up this material using material instances but for now we're just trying to get the video to actually display so now that that material is set up you just want to go ahead and go to your bp underscore tv go to static mesh and set the material of the screen to the new video to test matt so you'll see it actually changed so if i play you'll just have to wait for uh oh yeah wait i forgot something uh because we made our code module you actually have to go here so that's bptv this video to test media player you can actually set up in the editor what each tv displays so you have to click on your bp underscore tv go to media source and make it play the video to test now you can save that and hit play and you'll see welcome back to the youtube tutorial my name is my videos it's really cool there's a few problems which actually play video films now the biggest problem is actually is the fact that the video actually doesn't uh reflect or bounce light so it doesn't embed light so we want to fix that so let's go do that quickly just want to open the m video to test material and the thing you want to do is you want to go to the missive color on your video to test map drag off of that and create a new multiply node now you want to have the a value be the rgb value of the texture sample now the reason for that is it pulls the color information but it also mixes it with an emission value so that means that it will actually reflect the color of the video so more accurate light so super cool anyway um this b we're actually going to drag off and create a new scalar parameter and that's important to make it a scalar or not necessarily a scalar more parameter because we're gonna be using the material instances and you'll see why we're doing that pretty soon so you just want to make this emission amount and the slider max i would recommend you put that at maybe two the slider minimum should be and i would set the default value at one awesome now also another important fencing note is my tv actually was um already uvu wrapped pretty well but maybe yours wasn't and your video is actually rotated now i'll actually show you how to fix that by going here to your uvs you just want to go to your texture sample drag off the uvs and you just want to uh make a road yeah coordinates under coordinates you want to pick up and uh you don't want to do that just want to get a custom rotator of the miscellaneous now this uv uh you sort of just drag off that and create a new texture coordinate that's because we actually want this uv value to be zero so this won't actually really do much uh actually no we want the values to be one by one which is uh what the texture chord does and now this rotation center is uh the center point of the rotation now by default it's uh 50 50 which means it's right in the middle of the texture which is what we want and now this rotation angle we're actually going to go and again promote this to a parameter a scale parameter and this will actually be the rotation angle and the slider max should be what and the other default value should be zero because i'm going to show you something very cool and i can just hit save and let it compile um and this is the reason why we create all those parameters we're gonna skip now uh we're gonna skip all the shader uh compilation wow i'm i'm really bad today anyway uh you just go ahead and now you'll see well now it actually ref uh costs welcome to the environment tutorials now why did we set up all these parameters so what i usually like to do is when i create a material i like to create an instance of a material so you want to go to the material right click it and create a material instance now you can just click off and open that up and what's special about a material instance what's awesome is i can actually go ahead click or tick the submission amount and change it and it will actually change in real time and if i hit save it saves instantly it skips compilation entirely which is really handy i want my values to be one now here you can go to rotation angle and you can rotate it to fit your screen and because mine fits i'm not gonna actually rotate it but it's just important to know zero to one is zero to 360 degrees rotation not perfect that's already set up now before i go i'm actually just gonna um make the audio uh distance a bit better on this oh yeah wait we actually want to apply the custom instance material just want to go to your stats like this in the bp tv just want to go to the video to test material and just use the instance material and just save that um what's awesome about this is i can easily just go drag in the new tv and all the only thing you have to do is put on a new media player and the media source and we'll actually play a different video and you can just go to the start mesh set the material to a new material instant uh so i'm just gonna set that here and now they're both gonna play my that's super cool uh but that's really all for now thanks for watching guys if you like the content please subscribe hit like if you liked the video hit dislike if you did and see you guys next time good night everybody
Info
Channel: C:\Insert Name Here
Views: 1,274
Rating: undefined out of 5
Keywords: Unreal Engine, UE, Emission
Id: UoKLfaJ5In4
Channel Id: undefined
Length: 19min 39sec (1179 seconds)
Published: Fri Sep 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.