In this lecture I'll show you how to fix the problem where both all the play a character start in exactly
the same position.
So what we've currently got is a game where the server client starts and if you don't move your play
his position and then you connect another client it connects in exactly the same place.
And because it is connected in exactly the same place the rigid bodies of the objects interfere with
each other.
If you didn't have rigid bodies and collision detection on your objects then it wouldn't be a problem.
But in this case it isn't with most games you want to have physics in there.
So we want to stop the players at differing positions.
OK so this is actually quite an easy thing to achieve.
Spawn positions can be represented by any game object in the environment.
Once we've created them you want to add them to your network manager.
Select the network manage in the hierarchy and have a look down at the spawn info where we added in
the car prefab.
Underneath that is a place spawn method drop down box and a registered spoonbill prefabs section inside
this list.
Here is where we can add these starting points.
So to begin with in the hierarchy I'm just going to right click Add a 3D objects via And you can see
the sphere clearly in the game view which is just there and also in the same view because we're currently
working with a fixed camera.
I want to put these spheres somewhere that we're going to be able to see them so that we can watch the
cast born in different locations.
So for this feature I'm going to rename it to spawn point
and I'm also going to turn off the sphere Kolata because we don't want to play a character's physics
being interfered with by sporran like Haitian.
The only reason I'm leaving this mesh filter and mesh rendering on this object is so that we can actually
see it of course in your real Geim you probably wouldn't have those there.
Now we also need to add some special components that will allow these spawn points to work as spawn
points so that the network knows about them.
The first thing we want to add is a network identity so that we make the object network aboard.
And for that we can select it as a server on the local player authority.
Now this object isn't actually going to move anywhere or need to be updated.
In this case so this isn't really necessary to play around with it just means that the spawn point needs
to have a identity within the environment.
And the other thing the special thing that's going to make this a starting point is a network start
position components or make sure that you add that as well.
All right so now we have this Bourne point.
We can actually drag and drop it into your assets to create a prefab which is a spawn point and then
you can actually delete this one if you want to.
Or we can use it as a spawn point and just apply that to measure of law and up the prefab with this
instance and then grab another prefabs pin point and drop it into the environment.
The Ok so now I've got to spawn points so I just want to move this one just a little bit further away
so that when these cars spawn they're not going to be on top of each other and you can see those two
points there clearly inside the the game's camera.
Right.
So now we want to go to the network manager and actually register to spawn points with the spawn info.
The object when going to register is the prefab not the spawn points that are in here.
Just want to know what the prefab is.
So these spawn point in the assets we will drag and drop that into the registered spoonbill prefab list.
The other thing to take note of at this point is the method at which she applies will be spawned.
Now if you want them to be completely random then you can select random So if you get like 10 spawn
points in your game you don't really have control over where your players will start from.
And it could be purely by random chance that they both start on exactly the same spawn point which in
this case wouldn't be something that we want to happen.
So we've got we're actually working with to play characters and therefore having two separate ones and
making sure that they start on separate locations is more preferrable in this case.
So the spawn method is round robin.
And what that's going to do is put the first people who log in.
On one point and then the next people who are logging on the next point and then the next people on
the next point at siddur until it goes around all of the spawn points and gets back to the first one.
So if you actually have 10 spawn points and 12 people logged into your game then to lots of people will
be overlapping each other spawn point.
In this case we've only got to play characters and we're going to spawn points so that's enough.
So that's all you need to do to set up this starting on different position.
So let's have a look what that's going to work like.
So I've now created a client.
I'll start up the editor to host.
And what you'll notice is that the first car the player character for the server client version spawns
on this point at the top here.
And if we actually draw that Carwile see that it spawned over the top of that spawn point there.
Well you also notice that these two speeches don't appear to stop playing and then run it again before
I've created the network so there's no server running on here whatsoever.
The same might be here.
There's no spawn point you can't see them because there are network objects they don't actually get
instantiated until you've made the network so by clicking on the lane host over here to start the server
and the client it will actually also spawn your spawn points.
Then this one here when we connect the client the second car will start off in the second position.
And that actually fixes the issues that we have before they're all starting in the same point.
So that is how you add spawn points for different locations in your network environment and you can
have them round robin or you can have them random.