In this next project that we're going to build it'll be a tabletop tower defense game and it's going
to have three elements.
There'll be a mock up for your creepers or enemy objects.
There'll be another marker for your tower defense and they'll also be a marker for the home which is
where your creepers want to get to from this starting position.
So in this one we're going to add a lot more functionality than we did with the spelling game because
now we're going to be shooting bullets at moving objects and we're going to make sure that we can move
one augmented character from the position that they are spawned at on named Mokka to another Marcuse
position.
So first of all you will need a new unity project bring in the week chewed unity package and you'll
also need the package that is attached to this lecture which is called T.G. assets don't unity package
when you bring in that package it will give you a tower defense assets folder inside that folder you're
going to find all the extra assets that you will need including the Mokka Cod's themselves.
You can printout and also the W T C file which is called T.T. Cod's.
I've already copied mine across into my streaming assets.
We could choose and it's just here.
So make sure you get that out of your tower defense assets fold and bring it in here.
Now we also have a couple of sounds that we'll be using later on.
We have our Kripa object which is good and Gerbs and old unity character that they had many versions
ago.
I keep resurrecting him because he's just Noss as a character.
And he's got some interesting animations on him.
So we're going to use him.
This is a prefab set up ready to go for you.
We then have a home object.
And if you click on that you'll be able to see or inspect to see what it looks like.
Now unity also in the history will have a really nice tower defense beginnings project which has all
these really great assets so that's where I got these things from.
This will be a home object.
And then if you tick the tower or click on the tower you'll see what towers are going to like which
is basically a little gun.
So we'll might that shoot bullets at the creepers as they come past.
Now in the hierarchy I've already added the we captured camera deleted my main camera and added an image
tracker.
This is the default image tracker it has been set up yet.
So what I'm going to do is give you a little challenge.
Now I want you to go away and I want you to add three trackable objects under your image tracker because
you want one for the home card one for the card and one for the tower card.
Now on to each of those as the drawable object.
Make sure that you add those prefabs of goove the home and the Taua and then just test it out and see
if you can figure out what little adjustments that you need to make.
Before we continue so pause the video now go off and do that.
And when you resume all show you those steps to get that working.
OK let's get started.
How did you go with putting this together under your image tracker.
The first thing you need to do is sit your target collection to that T.
D.
Codd's that's now in your streaming assets folder.
And you also need to set your concurrent targets to three because remember we're trying to pick up three
different cards in this case.
Now the first trackable if we click on that automatically will have all of those cards selected and
it will just look for any of them and put whatever drawable object is on them.
We in this first case want to make this the Crable or Goob.
So let's turn off the home card and let's turn off the tower card and just leave that stop card which
is where the GUBA objects are going to start from.
Now we're going to grab Goober's prefab and drag and drop that into the drawable from here we can taste
just good.
Always good idea just to do one at a time and test them so that you know which bits going wrong if any.
OK so let's get my camera phone to start.
So when it did tech start you can see we've got GUBA and he is enormous.
So we probably want to scale that down a little bit.
Right.
So let's just stop that plane and I'm going to go to my prefab.
You could modify as we've done before if you find the mesh you could scale the actual mesh of goop.
In this case though you don't have to you can if you go over to the inspect and have a look under the
transform you can also scale that prefab in here.
It's currently set to 50.
I'm going to just set it to five instead just to make it a little bit smaller.
OK so now if we press play now let's find out Cod and we can test the size of that character which is
pretty good.
OK.
So we'll go with that.
This is a stock model the spawn point of where this character is going to come out of and multiple versions
of it.
So you don't want them to be too big.
Otherwise I will clutter up your screen really quickly.
All right.
So let's work on the next trackable So let's grab the checkable we've already created let's call it
crepe and then I'm just going to duplicate it and we will call this home.
And then we want to select it and make sure that the home card is active and that the stop code is turned
off.
We don't want the drawable Autum to be good.
We want it to be home so I'm going to drag and drop the home pre-fab from our tower defense assets folder
onto that position.
And now we can test it to see how we go so let's go ahead and find our home object OK we can see that
we've detected it because in this scene I've got my home come up.
But in my augmented view I don't.
So I can hold the camera steady for a moment and click pause.
Now what's happening let's have a look in the hierarchy we have home highlighted Mitch mentis Bane fan.
So if we did go down and click on things a bit his Alsheim object which is this heah he is our home
mock if we double click on Nash we're going to find that it's in a different location.
You can see here then the actual tear itself so the tail is off to the Saw a little bit.
In this case and we can click on the home object itself and you'll see that the position has it not
at 0 0 0.
So it is off to the saw it in the X and in the Xat even up a little bit in the wall.
So it's no way of sort of to be seen here.
If all we're doing this we just move this to zero or zero or zero.
They go in that same you can now see it even though it's paused It's pause the video feed essentially
but it's moved as objects are sitting over the top of that card and you can get an idea of actually
how big it is and how much you need to scale it from there.
Now you remember you can also do this same thing.
Let me stop playing pause.
Let's go back to the home and what we're going to do is turn on the preview for that home card like
that.
And then we can just get in a little bit closer move the scene around a bit and then we will get home
object drag and drop that on to home.
At which point it will be there so we can see that offset.
Now let's set it back to zero or zero or zero.
So now it's actually on the mark and from here it's a matter of figuring out what scale you want it
to be.
So if we change scale over the transform for that object to point five point five point five it's probably
a better saw as you can still say the card is not going to be overwhelming in your sane Sophronia because
you've now modified something that's in the hierarchy one I click apply in the inspector to change those
settings so that they go back on to the prefab and now you can delete that version of home out of the
sane and you're ready to test it again.
So let's find out home Cod.
There it is.
And you can now see that the relative size of that object is relative to the cod and exactly how it
did look when we were in the scene before with the Pravy on.
All right.
So that's good.
That is our home base let's stop playing that and we can now go ahead and add in our Talla So we're
going to duplicate home.
We'll call that Talla then we're going to make sure that we turn on the towel card for that drag and
drop Taua this time in to the dribble while we're here.
Why not do the preview so turn on the preview.
We will zoom in.
He will drag and drop tower onto the tail Mocca.
Again it's somewhere else in the world so let's say it's transformed to 0 0 0.
There it is.
And let's go back.
So that's really massive.
Let's have size as well because remember these two models are from the same game esate package so they're
bound to be in the same kind of scale case.
So that's a fairly big gun that's going to be aimed at Goob as he's going walking through you.
I was saying.
Right.
So let's save.
Oh sorry apply that Taua in the inspect up back to the prefab.
Delete that Taua and let's try it out so we'll play find out Telcom.
And there we go.
And we should be able to pick up all three as you can see the on those markers OK.
So that's the setting up all of your trackable images and each of the models even though this is not
exactly how we're going to do it the next step.
We do want to do however is spawn the Goob so that we get more than one come out of there.
But before we can do that we need that group to move off of that card to leave some space for the next
one to spawn.
Very similar to what we did with the zombie example much earlier.
Right.
So let's do that to move forward.
It's just really simple code that we've used before.
Do we create inside of your assets in your project.
I'm doing all of this and saw that tower defense assets just to keep it together say shop script we're
creating let's call it move and we'll open that up and edited the first thing you're going to need to
add at the top is a spade if you want to to be a variable controlled spade.
So let's call it spade obviously it's a float value and we will make it equal 0.5 F..
Now this is how fast your character is going to move.
And if you want to make it faster you would speed this up make it's slower than you would make it much
smaller.
Of course you want the spade to match the animation that's playing as well.
If you've got a character that say it's like a hover tank or something moving along then it's and it
doesn't have legs to go around and try to match the speed with bicyclists so you could have that going
at any speed.
Then in Updyke we will do a translation so this doctrine's form our trans light moving the character
along its axis which is its forward axis so 0 and 0 in the x and the Zed.
And then we will move it by spade multiplied by time delta time to smooth it out like that.
All right so I save that switch back to unity and then we're going to grab our movie script which is
here and drag and drop it on to the goove prefab.
Then click your good prefab chick over in the inspector that that new script is indeed attached.
And now we can press play and have a look if we can find a moving group.
So there we go.
And as long as that Mochis stays in your camera view then you'll be able to follow him as he walks across
my desk and then eventually he will disappear they.
At this point we've got a really good opportunity to have a look at a functionality in we could shoot
that we haven't yet looked at and it's not really part of this application I guess it could enhance
it.
Click on Kreep for way Goops coming.
Now you just saw that Google will disappear when the market is outside the camera view.
The nice thing about white cat food is has something called extended tracking and you've probably seen
that tick box over in your trackable objects sitting underneath the active for each of the cards and
wondering what on earth is this.
It allows you to track your augmenting object even when the market goes out of the sayne.
So how does it do that well it switches from looking for the Mac or in the camera fade to using the
slam method instead which we talked about in the introductory video and so it starts to look at the
environment itself and tracking feature points so that it can tell how the camera's moving and therefore
how the whole world should be rendered over the top of the video feed.
So let's see now if we can get Gabe to walk across my desk by clicking on that extended tracking.
OK so let's press play.
Now once we find where he goes we can follow him even when the market gets low.
So the Mac is a bet to get lost and he's now walking across my desk.
So the algorithm is now tracking what is on my desk based on feature points so there has to be enough
interesting stuff going on and then he's just going to wander off through the wall that it can do that
slam detection for the character to be a law and with the real world and how you initially set up that
real world.
Now we'll be using slam in the next section.
I will also being looking at extended tracking in more detail a little bit later.
But this was a really good opportunity to show you that now once you do turn on extended tracking.
Be warned it takes extra processing because the markets have been pre-trained.
It's looking for maake because it's tracking Mac because that's one way of doing this.
When you get into slam territory you using a lot more processing power.
So if you don't need it then don't use it.
So I'm just going to turn that off again.
We've now got our good character moving forward.
I'm going to leave this as a challenge for you until we come back in the next video.
And that is to apply a spoon.
So remove Goob as the drawable object.
And instead we want this to happen so it is exactly like we had with the zombies.
We want a sport where it's just going to keep producing.
Off to go off to so when we come back in in part two of this little series I'll show you how to quickly
put this together.