>> Hello, ladies and gentlemen,
boys and girls, children of all ages.
Yesterday we set up login system so that you can log into
PlayFab and we went over that flow of setting up
a form in Unreal Engine to do so.
Then we went through sign-up where you can register.
Now, the aim of this was building up
towards that to use the kind of data that you
can store against users on PlayFab
and one use of it would be to create a leader board.
We're still going to try and work towards that today,
but there was a slight little hiccup in the plan.
I can demonstrate what the hiccup was.
So if we go into this game,
so this is something that's been changed recently and then
now moved over to Azure Functions,
which I'm sure worked perfectly
well but what we're going to do today is still
learn a bit about what you need to know to set up a leader board
and we're going to do some client authoritative leader board work.
We're going to figure out how to do that.
We're going to figure it out as we go along this,
we're going to try and use some of the documentation,
we're going to Google search am sure.
We're going to try and figure things out and
that's what we're going to be doing today.
So if I go in and I look in the "Automation" tab here,
you can see that I've got this "Revisions" tab,
and in here this is how it used to be.
You could write functions,
you can do various things on the server.
We are going to do our best to
get started with a leader board, as I said.
So let's get started with that.
I could login. I could go into already signed up.
I could type in my e-mail address,
and then I could log in and then it took us to this level.
The first thing we're going to do, I'm going to move
my login widget to be the first one,
just so we start on that one.
Second thing. I want to be able to just fill
some text into the e-mail and password.
So let's go into here it's going to be super quick.
We're just going to get our input field, just like before.
We're going to promote this to a variable
and now what we should have,
we have the ability in our login widget to
click on these and set some pre-fill text in here.
Okay, so that should be saved now when we press "Play",
I can just press "Login" straight away.
I need to give control back to the player.
So I'm going to just do this,
but we want to do this in the second level that we made.
So we made a level called post PlayFab login.
It's going to be set input mode.
So this should allow us hopefully to be
able to have control once we've logged in.
We can move around now at least so we're not locked in place.
Yeah. First off, we're going to look at
what I said was titled data.
So you find this down in the content section.
So let's click on "Content" and in
here is where our title data will be.
So I've got one that I've made from before.
I wonder, can I just get rid of this?
Does it not let you just delete one?
Surely you can delete, can you? Yes, you can. There we go.
So it's no longer there. This is what
it would look like if you're coming in.
In here, we're going to add a new one.
We give it a name, so this'll be enemies
per wave and then we're going to put in a value here.
So let's say at the moment it's going to be 10 enemies per wave.
So we're going to press "Save" and that is up to date now,
that's all you need to do, but we should have
a look how we can actually go ahead.
Let's go to Unreal and we're going to go if you remember
all our PlayFab interactions yesterday were via app game instance.
So we're going to go back into that PlayFab game instance we made.
We want to go ahead and use our PlayFab API
in order to get hold of that data that we just made, right?
So first off, let's make an event that we can call, shall we?
Okay, so we're just going to
pretend that we've got a bit of a back-end game on it.
We're just going to make a function.
We're going to add a custom event for now,
I guess we can just print it, number of enemies.
We need to call one of those PlayFab functions.
Let's have a look what we've got available to us.
So we got, Get Title Data and we're going to go ahead and click
on "Get Title Data" but we're going to drag this
out and we're going to see what does it need in order to,
we're just going to go ahead and type in
our key and it's called enemies per wave.
Let's just copy paste that in.
We're requesting the title data that's called enemies per wave.
Because it gives you the same signature back,
we can just keep reusing that, which is lovely.
Now that it's been a success.
Before what we did with the success,
if you remember, is we just loaded a map, right?
Because all we needed to know is, oh, we logged in.
Like before we're going to go and we're going to break this dam.
So let's do a Get string.
We'll do that and then we can make sure that we plug
that same value in over here.
All right, so now that we've gone and looked at this,
we're getting some data back and now we can just use this data.
We've got it as a string,
we're going to give this a go and I'm going to show
you it not working first as well.
Let's go to our player character.
Go get number of enemies from PlayFab.
Let's have a look what happens.
This is the level where we're going to be logged
in to and this is going to be the first example of it going wrong.
So let's see. So I press "K" I said it'd go wrong,
but I didn't expect it to go wrong in this way, intentionally.
All right, let's press "Play", I press "K".
Can you see that this says 10,
very small in the top of the screen.
It may not be too exciting.
Let's make it really difficult.
We now get 60.
I just made the game really hard.
That dynamic data is pretty interesting because we could use
that information in order to change the game-play.
So shall we do something very simple to
demonstrate how it would change game-play?
We're not going to go very complicated at all.
So let's see whether or not we can request it as
a number or whether it does come through as a string.
So let's press "Play" let's press "K".
It still does come through.
So it does read it for us. It'll send it along.
Yeah, you can see a 60.0 there.
So good. We can test this quickly
so we should now get three enemies spawn.
Great. So that's just a basic spawner, right?
But the idea here is we can feed
that value via PlayFab instead so we can change it dynamically.
So now what we need to think is how can
we arrange the flow of that data?
I guess what we could do is we need to think about how
we're going to get the call back from this to this data,
we need to go ahead and set it in our enemy manager.
We can get around this in a nice easy way.
Let's just go ahead and make a variable and
this is going to be public so we can access it elsewhere.
So then when we get this back,
we'll print it but we're also going
to go ahead and set this value, right?
So let's hold Alt, drag this on,
it's going to be truncated and because it's
treating it as a float, but that's fine by me.
We want to give PlayFab
a chance to come back to us and give us the answer,
and then what we want to do is
our wave spawner wherever I made it wave manager here,
we're then going to go ahead and spawn enemies that way.
What we're going to do is we're going to go and get that and
value from our player instance, game instance.
We want to cast this.
Then what we want to do is we want to get hold of
that number of enemies per wave
and now we don't need that local variable anymore.
That works fine for me.
So let's go back to our game.
We'll go back to the main level.
They have login level, okay,
so we'll give this a default value of one.
So if there's only one enemies spawning we know it's
using the default but if we get five spawning,
we know it's reading from PlayFab.
Okay. So I press three seconds goes by.
Okay, here, can you see it says not authenticated.
This was the error I was trying to show you
earlier but I think once you login once,
you're authenticated for a session,
then perhaps, and I think maybe that's why it worked earlier.
So you've got to make sure that your player logs
in so that they can make these requests and
now we get our five enemies
spawning because it read the value from PlayFab.
So yeah, that's one use of how you can access data that's on
your PlayFab title and we're going to now try and progress
that a little bit to look at statistics instead,
something called Azure Functions.
So if I go into players, what's my name, Dan?
Okay, I just had to search it and you've
got all of these different types of events now.
So play stream events are a bunch of
already implemented PlayFab hooks.
So when the player logged in it will fire
this event and you can hook into it.
This is where then you can add action.
Whenever we get this Event is how you
stall individual data and it can be strings.
I think you can actually store different types of vectors as well.
I don't have an exhaustive list here to go through.
I've gone about this is if you were to create a leader board,
it'll automatically go ahead and create a statistic for you,
which is going to be what you are tracking in that leader board
there and let's make a new leader board and
we'll call this top kills if we're doing
a shooter game and now you can see we
have a leader board and has no results,
which is a sad state of affairs.
I know, I'm sad too,
but we're going to try and figure out now how we write to
this but for now we're just going to like we did,
bind it to a key and just call it.
We're going to go ahead and we're going to make a new one now,
we're going to create a custom event as well.
We have our own failure and
our own request so we can do the failure quickly.
We'll just do a create event.
We'll call that own failure that we've been
using the whole time. Happy Days.
So this'll be import,
let's just do L this time because it's next to
K and we're going to give it a new number of kills.
So let's just say we have killed 10 people this round.
Let's see what happens shall we?
Is it going to work for us?
Is it going to add anything to it?
So we press "Login" stats were sent.
How exciting, okay, holy smokes.
We've got a little bit of leader board data going in.
You can control which way
the statistics are updated and that's
important based on how you're doing it.
Okay. So that was straightforward.
I'll tell you what, shall we go ahead and add
someone else into our data base as well.
All right, so now if we went into the statistics of Steve,
and so if we say okay,
Steve has got most kills in a game of 80 so Steve is really good.
We then press "Save", if we go to
leader boards and most kills in a game,
we can see that Steve is roaring ahead of Paul.
We're going to have a look now how we can
try and get hold of that information to pull it back.
So I haven't done this before,
but using the PlayFab API is pretty straightforward.
You normally just type in some of
the keywords and there's a function for it.
The nice thing about this is it's safe again, the leader board.
So the client can do this without you feeling like it's
a risk because all they're doing is reading data.
So shall we have a look if we can figure
out how to do it, let's make a new event.
This is going to be get leader board.
We want to go here.
We're going to call PlayFab function,
probably going to be called get leader board.
The specific version I don't need that,
the string field is going to be display name.
Copy that, Get ourselves a divider again.
Finally, we want to get the kills.
This was right. Okay, we're going to see if it works.
Tiny leader board in the top left of my screen.
Oh, I'm excited.
Let's login and now we just got to press "J".
There it is, it happened so quick,
we've got to screenshot it and then we're going to make
this giant so we can appreciate it in all of its glory.
Look at our leader board.
It's a thing of absolute glory.
There we go, position zero and one, but yeah, okay,
so hopefully today we've had a nice little insight
into how we can store data,
retrieve data and use it in things like leader boards.