So far we've added physics and spheres into our scene and we found that there's different ways to present
this phase with respect to the plane.
Now if you want the speeds themselves to disappear when the grid disappears because the tracking has
stopped we have to look at a different method and the way to do that is to disable the renderer of the
SPia.
First of all select the sphere what the sphere is going to need is a tag.
And in this case I have already tagged this via with SPia.
So in your Inspectah create a tag holds.
And then make sure you assign it back to the SPIE prefab.
Now we go back into the code so find your scene and I will say it's in an old method and this is where
we're turning the grid on and off based on whether we've lost or found the sane or lost it or not.
Under Yahia when the grid is disabled we're going to loop through all of our game objects that we want
to turn off and turn off their render.
So this is the code that I've just added.
Let me go through it for you.
First of all we're creating an array of game objects and we're going to populate that with find game
objects with tag using the tag that we just added.
Then we loop through this entire array for each game object.
We get hold of its renderer So I remember the Render is the pot making it visible in the environment.
We can enable or disable the renderer down here based on what comes through as this bhool in the sitte
scene and I will so it's going to look through Tramon loop through and turn it off.
The beauty of doing it this way is that you disable or enable the Render to not the game object.
So everything else about the game object the physics and the positioning movements of speed.
Yeah.
Well it's pretty much all physics related isn't it.
It keeps going gets keeps getting simulated in the environment so that when you're not looking at it
or when it's not being tracked the environment keeps going which is what you may want in your experience.
OK so with that in just PR-STV now we're going to go back into unity and try this out so we'll press
play.
Going to turn my camera down to the ground again start tracking.
Let's add a few holes into the scene.
OK.
To offset time
OK say rolling away and it disappears.
But if I come back I should be able to pick them up again.
I just saw them at the top there so I wasn't tracking very well that time let's just stop and start
tracking again.
That's track check check too we can see in the distance so you can see those of bulls just up there
in the distance so they still exist.
Even though I've started and stopped the tracking can see them right there so NEFA and these ones in
here.
And then just really go up lose everything come back when it picks up the environment and you can say
that they're now just mice disappearing the top but they're still simulating for us.
So that's a really good thing.
And that's what we want in this case.
So any object that you put into you're saying that you want to Renda and you want to turn off when the
tracking is not happening then you can give it a tag and just add in another look for it in sort of
your control and that's the same thing that will do with the zombies when we add those.
Now before we do that zombies just want to hook up this slider that we put in the beginning which is
currently not doing anything.
The code is really really simple but do note that the code is only going to work when you build it out
to a mobile device and I'm putting this in here because there's just enough room left in this video
to do it.
And it's a really simple task to achieve.
So if I open up your controller you want to add in a method that I've already got in here.
Let me just see if I can find it.
It's like a one liner.
Here it is.
K so it's public void on heart value changed.
It's going to get a float value that comes from the slot and then what it does is go check the device
height above ground equals the value that you set it to.
So that value that we've got that goes between 0 and 2 on the slide that is the height above the Grand
in matres.
Now you'll see how this changes the grid as you slot it up and down and basically just makes the grid
sizes bigger or smaller.
But what it's also doing is scaling the world Kyser remember it's not going to work in here an editor
and you'd have to build it out to see it.
But let's just hook it up so add that in save your code go back to unity then let's find us law and
it's here.
Now I think I've already got this hooked up anyway.
But to do it select the slaughter and then go down in the inspector to the bottom.
So do I do have it hooked up so you want to press the plus button to add a new section in the drag and
drop your controller on to the air and then you want to set the function and find the control function
for on height value changed.
And now that slide a value will change in the code which will affect the tracker device height.
So it was just a Noss really simple thing to add the end of this video.
And then next lecture we will start spawning the zombies and have them attack or at least have them
come towards the camera.