Advanced Godot | Integrating Facebook Ads Into Godot!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys this is mitch with fine point cgi and today we're going to talk about integrating facebook advertisements into godot so we're going to talk about the facebook ads plugin we're going to go ahead and set it up so that we can uh build that facebook plug-in we're going to set it up because most of the code is actually set up for us then we're going to do a little bit of testing and setting up in facebook and then we are going to go ahead and go over all of the code that facebook advertisement offers and how it works on a fundamental level so that way we can actually understand how the link is made between the java code and the godot code so i kind of run you guys through that a little bit and we have a small conversation on that i don't get into any java actual java code but i do give you guys a little bit of information on that so that's what i have in store for you guys today so let's go ahead and get started okay so the first thing that we're going to talk about is the add-on that we're going to be using to interact with our facebook audience network so we're going to be using the godot fan add-on created by mr zac dash dev you know this is a really cool add-on and he has a lot of code that's just built in that makes this really simple for us so we're going to go ahead and download this so let's click on our little green code icon and click on download zip now i've already downloaded it so it's going to be pretty quick actually i've downloaded three times because i had some corruption uh go on with my recordings so of course right so we're gonna go ahead and hit extract all and we are gonna extract all right so now that we have the add-on here let's go ahead and start our godot project so let's go ahead and and start godot all right so the first thing we're going to do is we are going to go to project we are going to install our android build template if you haven't already so we'll go ahead and install that and we're going to click install and that's going to uncompress our android build sources so it should take a few seconds and we will have those real quick now from here we can go ahead and go to our project export let's add in our android export and let's come in here and turn on custom build right here so go ahead and click on our check box right there and from here we have everything that we need to get started with putting in our add-on so we'll go ahead and click close we're going to right-click right here and we are going to go ahead and click open in file manager and that will go ahead and open up our project so we'll go ahead and click on android right here and we will stay right here we're going to go out to our godot fan project that we've exported here and you can see i've extracted it right here so we'll go ahead and go into our godot fan and we need to grab our godot fan folder we're going to go ahead and click ctrl c and ctrl v and what that's going to do is that's going to copy and paste it into our android folder now one of the coolest things about the godot fan add-on is it actually taught me something so prior to [Music] using this add-on i always thought you needed to compile all of your add-ons into these binary files that godot can use but it turns out that you can just paste it in here with your build.gradle file your little gradle config file and it'll actually build it on build it'll actually build it with the gradle config and it'll use that as like a settings file almost so it actually saves a lot of trouble for us and it's a new way of interacting with godot and i i didn't even know that was a thing you can still com you can still compile it as a binary and drop it in and use it as a plug-in but this is another way of handling it and it's actually a really cool way to do it so we're going to go ahead and go back to android and we have all this setup and everything's good to go here so we're going to go back into godot and we can see that we have our godot fan project right here now we do need to do some setup here what we're going to do is we're going to go up to our project project settings and then we are going to scroll down until we get to compression right here and we are going to go to android and you'll see that we have a section here called modules and these are all of the modules that your project has now the easiest way to know what your module is going to be named is to actually go ahead and look at that godot fan java project if we actually go ahead and we open it with visual studio code we open this up you can see that it opened up my c-sharp tutorial but if we go ahead and we take a look at you can see that we are part of the package org godot engine.good oh and then we are the godot fan class so we need to call out this section here inside of godot so we'll paste that in and we will need to change these to slashes to tell godot where it needs to look and we need to go ahead and call out our class so we'll say the doe fan now what this does is it tells godot hey i need to go into the org godot engine godot location and i need to find the godot fan and i need to make sure that i include this with my build if that makes sense so now we can go ahead and close this and we can go and create a 2d scene now from here we have a couple of options we can either build our entire plugin from scratch and do all of our hooks and things like that or the developer of this little plugin has actually put in one for us so if we come up to our ads example so we can just take this and bring it into our project so if i open up our godot ads tutorial and i copy this and i paste it in now when i go into godot you can see that i have a little gd script now this gd script has 90 of this stuff hooked up for us so we don't have to do it so i'm gonna go ahead with this and then i will walk back and explain to you how all of this works so if you guys want to do it yourself you guys can so we'll go up to our project project settings we'll go ahead and go into our auto load and we will go ahead and add facebook ads as our singleton here so we'll go ahead and add that and what that's going to do is it's going to create a singleton for us to be able to call when we want to do our facebook advertisements so we can just type facebook ads dot and then we can have access to all of the functions inside of here it's a really cool way to have repeatable patterns that you don't have to have a bunch of object references so from here what we need to do is we need to go ahead and create a ads manager so we have our facebook ads but we don't have an ad manager in the scene so let's go ahead and right click our node 2d let's attach a script and call it ads manager go ahead and add that in and then we need to do some fancy calls here well they're not really fancy but they're they're fancy enough so what we can do is we can right click on our node 2d add in a child node let's add in a button and that's going to allow us to have a button that we can test our banner ads with we're going to go ahead and duplicate that and do the same thing down here and duplicate it one more time and drag it down here and we're going to call this our banner button we are going to call this one our interstitial button and we are going to call this our rewards button all right now we're going to need to link all of these back to our script here so we're going to change our text and call it banner and we're going to go to our node and we're going to say on button down go ahead and connect to our node 2d it's going to create our function down here now that's going to create a signal it's going to connect our button with that specific function so that way we can call this code when that button's clicked so we'll come to our enter button we'll do the same thing so we're going to call this enter because i can't spell interstitial to save my life we'll go to node we'll click button down and then we'll go ahead and add that function in as well and we'll go to our rewards do the same thing button down on rewards button and we'll go ahead and add reward all right let's go ahead and save our scene and i'm just going to save it as node 2d because i'm a heathen and i don't uh really need to save it as a specific name and what we're going to do is we're going to say hey when you press your banner button we need to show our facebook ads right so facebook ads dot show facebook banner right and then we need to go ahead and and wait a spare a period of time because we want our ads to show up for a little bit of time and then we want it to hide right so that way um we can serve another ad to them so they can click the button and it'll show them another ad right so we can say yield get underscore tree dot create timer and we're going to give them a 10 second timeout right and we'll say we're going to wait for our timeout function here and then we're going to go ahead and hide that banner simple enough now from here we have to hook up our interstitial advertisement so if we come in here and we go ahead and just legitimately type facebook ads dot show interstitial that's all we need to do and if we come down here we could just type facebook ads dot show reward and that's all we really need to do to hook up our little class here that's it that's how simple this guy has made our system now there's some more additional setup that we're going to need to do but for the most part that handles a large sum of our work here now we just need to go ahead and set up our facebook ads here so if we scroll up to the top you'll see there's a section here where it says hey i need these advertisement ids so we're gonna need to go to facebook and pull those advertisement ids so let's go ahead and do that so we're going to go ahead and open up our facebook monetization manager here and you can see that i actually have a couple of properties here already built you can actually see i've recorded this advertisement tutorial once already but that's okay so i'm going to go ahead and create a new property and we're going to call it facebook ads tutorial we'll go ahead and create that property and we're going to go ahead and go down to android and we are going to say yeah that's good it's all good and we are going to go ahead and click next if you have a app out on google play you can put your url here your app name and your platform here and that will link it up so that way google facebook will send you actual advertisements once your app is verified on facebook then you are eligible to make money for it if you don't fill this in you will not get advertisements unless your application device is in the testing device section which i will show you guys once we're done setting all this up so just to keep that in mind fill this in or you won't be making any money or get advertisements and nothing will work unless you have your your device in the testing application section okay so let's go ahead and click next and add a payment account generally they won't give you money unless you add a payment account i don't need it so we're gonna click next and here we get to pick our first advertisement and i always start with banner that's just how i do all my tutorials so we'll click on banner we're gonna click next all right so you'll see an error occurred when uh we do this but we got no i don't know if i'm worried about that let's see yeah my email hasn't been confirmed that's fine yeah we should be good so if we go back home [Music] and we come down here we click on our three dots we go to manage property you can see that we already have an android ad space and that was created by default by facebook so we can go ahead and click on that and you can see that we have our banner here so you can see that our display format is banner it is ready to publish which is cool and we accept any price and this is something that facebook does is it allows us to bid for a specific price well it allows other people to bid on our app for a specific price most of the time i just accept any price because i don't really care right as long as i'm getting money who cares right but some people are like i don't want you to serve ads to me if i'm you're not going to get me x amount of dollars per thousand views right so it's just something that you're going to have to square away with yourself on how you want to handle it so you see here we got a placement id if we click on this we can get our code so we'll go ahead and copy that i'll go ahead and open up godot here and we will go ahead and go into our banner placement id i will paste that in and control s we're going to go back to our monetization manager we're going to create a new placement and we need to go ahead and name it and i will call it inner because i actually already did this once and we will come whoops uh please enter and we will go ahead and call it an interstitial advertisement we're gonna scroll down and we can do what's called frequency capping so if a person's playing your game and you don't want them to see advertisements after x amount of advertisements per hour then you can set that up so that a person may not see advertisements if they play your game a lot that can encourage people to play the game a lot because they're you know it reduces the amount of advertisements that they see in an hour so it can be really useful for you because instead of targeting them every single level you're targeting them x amount of times per hour so it can be easier to kind of hook your player into playing your game without getting hit with advertisements as much now you can see here that we have waterfall pricing which is saying hey you know you can actually select a price and then they will deliver ranges higher and lower but it'll be within that range right so it's really nice if you're trying to make a specific target cpm you can actually set that here but we're going to go ahead and click create placement and you can see that we now have our placement here so i'm going to go over here you can see we're accepting any price and it's interstitial format so we'll grab that code right here we'll copy that we're going to go back to godot and we'll go ahead and play paste that in right here go ahead save and tab back over and finally we got to create our last one which is our banner ad or our reward advertisement so we'll go ahead and call this reward and we will scroll down here and do a reward video and i'm good with whatever and we will go ahead and create that placement as well so you can see we've already created it so we'll go ahead and copy that placement id we'll tab back in here and paste it in so now we have all of our ads set up right here it's all done right so now if we were to run this on our phone we wouldn't get any advertisements why is that right well the reason why is because we haven't officially released our application so facebook will not deliver advertisements that are real until you release your application so what you need to do is you need to set up your application to be a device to be a test device so if we go back to facebook and we go over to testing you'll see that there is a section here for testing now go ahead and turn on testing enabled and come down here and enter your devices idfa or aaid what that is it's your unique identifier that google and ios uses to find your advertisement id now in my case on my specific phone my advertisement id is located in if i flick up and i come down here to my settings and then i scroll down like this and i go and i find google and i click on google and then i scroll all the way down you can see there's fine point cgi there's my gmail and you scroll down you can see ads click on ads you can scroll down you can see right here is my unique advertising id now i can just reset it and regenerate my id at any time it's not something that's safe or anything that's like dangerous it just has some of your personalized information things that you look at things like that so if you're a big security conscious person don't show this on the internet but i'm a youtuber so i'm just going to show it on the internet it's fine but that's something that you will need to input into this box right here okay and then you got to put your name in my case there's my name now from here we need to select the advertisement type that we're going to show so if we click on select add type you can see we have a bunch of different choices here and all of them are super useful in my case i'm just going to use an image because it's the simplest and it just it's just easy to test your stuff so if you just click test image bam it's done now when you load your application onto your phone you can go ahead and just start using it so let's go ahead and do that let me go grab my usb cable and hook my phone up and we'll go from there okay so now that i have it plugged in you can see usb debugging has kicked in if i go ahead and i come up here and i click on my little android guy here if you don't have that you need to make sure that you have usb debugging on and you need to make sure that that your phone is in developer mode the only way to do that and i'm going to make a short on this shortly but the only way to do that is to come in here go into your about pixel and scroll down there's a section where you can see your build number if you tap that a bunch of times in my case i don't need to i'm already developer but if you tap that a lot it'll enable developer mode and then you can go and find your developer options i forget where it's at so if we go into system and then we go into developer options then you can see all the different developer options that you have and you need to make sure you turn on usb debugging right here that's the important one and that will turn on your little android guy also you can turn on wireless debugging if you want and that will allow you to have wireless debugging with godot as well so that's something to keep in mind as well now if i hit home and i click on my little android guy it says hey no main scenes have been defined so let's go ahead and select one let's select our node 2d and go ahead and open that up so you're gonna see it's gonna start building it for us and it's gonna go ahead and dump it out to my android device so i will be right back okay so you can see that it's loaded let's go ahead and click on banner and you can see our banner has popped up perfect that's exactly what i wanted if we wait about 10 seconds it should go away awesome that's what we wanted so if we go ahead and we click on interstitial you can see we now have an interstitial that popped up perfect that works great and if we close this and we click on rewarded you can see it's fired off a rewarded advertisement which is great because that means that we can have people watch our videos we can give them rewards now the question is is where does this reward get fired right so if we close this you said nothing changes but we can tell that our reward callback got called because if we come into a command prompt we open that up we bring it over here and we run a regular expression here for our adb so if we do adb dash d log cat godo fan colon v space fan colon v space godot colon v space asterix colon s you will see that we just get our godot our fan and our uh godot fan um callbacks so it's really useful for debugging we don't have to deal with all of that garbage that we had to deal with before and this works for everything by the way if you can figure out what the um what this value is here you could just kind of add that at the end and just say colon v and then it'll just pull that data back so it's just something to keep in mind but you can see that we had a banner that loaded we had an impression we hid that banner we did an interstitial ad it was dismissed and it was reloaded so i'm curious if we click on banner what happens yeah it reloads it so that's good now if we come down here you can see we have a reward ad it got completed and closed and we gave them a reward and if you come into your facebook ads section and you scroll down you can see that there's a section called give reward so you can actually inject right here whatever you want to do so you could go and say okay well let's go set their token value to plus one right or something like that you could keep track of all of that right here and it would be fine so i mean that's basically all you need to know to integrate facebook advertisements into your game you know from here you guys have the grounds to do everything you have you have everything under you to do all this so if you want to stop here you guys can but i'm gonna go through and kind of explain this a little bit so you guys can kind of see how this operates so the first thing that happens is hey it pulls back facebook or it creates a facebook variable here and it creates a facebook id variable section here which is good so it creates a little object that our dictionary that holds all of our facebook advertisement ids it's just easier that way if we come down here you can see that on start it comes in here and initializes facebook you can see that it's looking for a singleton if it finds it then it goes ahead and sets up our facebook advertisements and then it loads a reward video and loads a banner and the reason why it does that is it's trying to pre-load this stuff so that way you don't have to deal with the system loading when you want to show them a reward video or a banner it's just smarter to handle it that way now now from here it has a bunch of different functions so it has a function like load reward right which loads a reward video facebook.loadrewardvideo um it has on reward ready is facebook reward ready true so it's saying hey when the reward is ready go ahead and um you know set it so that way we can show that reward video now you could just straight up call the reward video from here so as soon as it loads it it calls it and that is a method of doing it it's not a good method or a bad method it's just a method now the other one is interstitial you can see on ready it does that on closed it says hey facebook interstitials ready is false so that's fine you can see here we got a call back here for on reward closed and it says hey load our reward video and then if it's completed go ahead and give them a reward on reward completed go ahead and set completed to true so basically what happens is it's going to give you a callback saying yep they've completed it and then it's going to close so that way you can make sure that they've actually watched your reward without closing out before you give them the reward so this is really smart it says hey they've completed the reward so give them the token once they close so you could either do it here if you wanted to you could say hey once they complete it they get the token or you could say once they've closed it closed it if they've completed it then they get the tokens it's up to you guys there now you can see here show facebook rewarded what it does is it checks if it's ready right if it if it's able to show the video and then it goes ahead and shows the video simple enough and you can see here show facebook interstitial it checks if it's ready to show and then it shows the interstitial simple enough same thing with loading your facebook banner it loads the banner and you can see here that we have a little variable being passed in here or if it's on top so you could actually load it and say true and what that would do is i would pass the banner to be on top and then they have show facebook banner which shows the banner and then they have hide facebook banner which hides the banner now something that i think would be fun is if i actually copy this let me i know i'm going really in depth here and it's probably not even needed but i really can't yeah i like doing this kind of stuff for you guys so if i come over here and i actually open this up here and i go into my android and i go into my godot fan and i actually open up that java file you can see if you scroll down here there are functions that are public void here that directly correlate with what you're trying to do so you can see facebook adds a nit which directly correlates with facebook ads a net right here load interstitial directly correlates with load interstitial if i can find it facebook dot uh where is it you know actually it's weird they actually don't call it they must call it inside of here somewhere but you can call load interstitial from here and it would work um if you come down here you can see load reward video and you can see load reward video right here load facebook reward right so this has if i can find it has a section down here and you can see right here these are all the classes that you can call with this plug-in so one of the things that's really cool is if you ever get a plug-in where they don't have any documentation you can actually come in here and literally look right here and it'll tell you all of the classes and you can actually come in here and say let's say hide banner and control f and if we find that function hide banner that's the actual function right here so it's really useful if you need to understand how things link up you can actually come in here and say oh they got a height banner it links to this function and then it runs this little bit of code so it's really useful for debugging so that's just something to keep in mind i thought you guys would appreciate it so if you guys didn't let me know i'm always of course open to feedback if you guys don't think that this kind of stuff is useful but that is all i have for you guys today so hey if you like this video go ahead and hit that like button and hey you know if you dislike this video go ahead and hit that dislike button because i am here to make content for you guys this tutorial as with all of my tutorials was a viewer suggestion so if you have any suggestions let me know in the comments below and i'm more than happy to get to them as i've said before the list is long but i will always get to your requests it might take me a while but i will definitely get to him and hey if you have any questions or anything or any feedback that you have for me throw it in the comments below or hey hit me up on my discord link is in the description below to go ahead and ask me i'm always looking to help you guys out and discord's one of the fastest ways to get a hold of me [Music] but that's all i have for you guys today so thank you so much again for watching and i will see you all next time thanks [Music] you
Info
Channel: FinePointCGI
Views: 335
Rating: undefined out of 5
Keywords: godot, godot engine, facebook, godot game engine, godot tutorial, godot engine tutorial, what is godot, godot beginner tutorial, intro to 3d in godot, godot engine firebase, gdscript intro godot 3.2, godot android, godot for android, facebook interview, godot explained, how to create a facebook ad, godot ads, facebook ads, learn to animate in godot, godot firebase plugin, godot google firebase, godot firebase tutorial, godot engine juego web, facebook friends
Id: qQjgb-SzC8E
Channel Id: undefined
Length: 31min 58sec (1918 seconds)
Published: Mon Nov 15 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.