1
00:00:04,310 --> 00:00:10,300
In this lecture I'll show you how to fix the problem where both all the play a character start in exactly

2
00:00:10,300 --> 00:00:11,850
the same position.

3
00:00:11,860 --> 00:00:20,070
So what we've currently got is a game where the server client starts and if you don't move your play

4
00:00:20,080 --> 00:00:26,830
his position and then you connect another client it connects in exactly the same place.

5
00:00:26,850 --> 00:00:32,700
And because it is connected in exactly the same place the rigid bodies of the objects interfere with

6
00:00:32,700 --> 00:00:33,460
each other.

7
00:00:33,690 --> 00:00:41,720
If you didn't have rigid bodies and collision detection on your objects then it wouldn't be a problem.

8
00:00:41,970 --> 00:00:46,560
But in this case it isn't with most games you want to have physics in there.

9
00:00:46,560 --> 00:00:50,460
So we want to stop the players at differing positions.

10
00:00:51,750 --> 00:00:56,020
OK so this is actually quite an easy thing to achieve.

11
00:00:56,070 --> 00:01:00,800
Spawn positions can be represented by any game object in the environment.

12
00:01:00,900 --> 00:01:05,600
Once we've created them you want to add them to your network manager.

13
00:01:05,760 --> 00:01:11,610
Select the network manage in the hierarchy and have a look down at the spawn info where we added in

14
00:01:11,610 --> 00:01:13,360
the car prefab.

15
00:01:13,740 --> 00:01:24,950
Underneath that is a place spawn method drop down box and a registered spoonbill prefabs section inside

16
00:01:24,960 --> 00:01:25,880
this list.

17
00:01:25,880 --> 00:01:29,910
Here is where we can add these starting points.

18
00:01:29,910 --> 00:01:39,430
So to begin with in the hierarchy I'm just going to right click Add a 3D objects via And you can see

19
00:01:39,430 --> 00:01:46,240
the sphere clearly in the game view which is just there and also in the same view because we're currently

20
00:01:46,240 --> 00:01:48,290
working with a fixed camera.

21
00:01:48,520 --> 00:01:54,730
I want to put these spheres somewhere that we're going to be able to see them so that we can watch the

22
00:01:54,730 --> 00:01:57,340
cast born in different locations.

23
00:01:57,340 --> 00:02:01,660
So for this feature I'm going to rename it to spawn point

24
00:02:04,850 --> 00:02:10,640
and I'm also going to turn off the sphere Kolata because we don't want to play a character's physics

25
00:02:10,640 --> 00:02:14,680
being interfered with by sporran like Haitian.

26
00:02:14,730 --> 00:02:20,730
The only reason I'm leaving this mesh filter and mesh rendering on this object is so that we can actually

27
00:02:20,730 --> 00:02:26,170
see it of course in your real Geim you probably wouldn't have those there.

28
00:02:26,300 --> 00:02:35,610
Now we also need to add some special components that will allow these spawn points to work as spawn

29
00:02:35,610 --> 00:02:38,390
points so that the network knows about them.

30
00:02:38,430 --> 00:02:44,810
The first thing we want to add is a network identity so that we make the object network aboard.

31
00:02:45,090 --> 00:02:51,660
And for that we can select it as a server on the local player authority.

32
00:02:51,660 --> 00:02:56,160
Now this object isn't actually going to move anywhere or need to be updated.

33
00:02:56,160 --> 00:03:03,120
In this case so this isn't really necessary to play around with it just means that the spawn point needs

34
00:03:03,120 --> 00:03:07,520
to have a identity within the environment.

35
00:03:07,830 --> 00:03:14,480
And the other thing the special thing that's going to make this a starting point is a network start

36
00:03:14,480 --> 00:03:18,740
position components or make sure that you add that as well.

37
00:03:19,820 --> 00:03:22,280
All right so now we have this Bourne point.

38
00:03:22,280 --> 00:03:32,370
We can actually drag and drop it into your assets to create a prefab which is a spawn point and then

39
00:03:32,370 --> 00:03:36,080
you can actually delete this one if you want to.

40
00:03:36,240 --> 00:03:43,920
Or we can use it as a spawn point and just apply that to measure of law and up the prefab with this

41
00:03:43,920 --> 00:03:50,480
instance and then grab another prefabs pin point and drop it into the environment.

42
00:03:52,220 --> 00:04:00,680
The Ok so now I've got to spawn points so I just want to move this one just a little bit further away

43
00:04:00,710 --> 00:04:05,510
so that when these cars spawn they're not going to be on top of each other and you can see those two

44
00:04:05,510 --> 00:04:09,290
points there clearly inside the the game's camera.

45
00:04:10,490 --> 00:04:10,780
Right.

46
00:04:10,790 --> 00:04:19,130
So now we want to go to the network manager and actually register to spawn points with the spawn info.

47
00:04:19,130 --> 00:04:25,290
The object when going to register is the prefab not the spawn points that are in here.

48
00:04:25,310 --> 00:04:27,560
Just want to know what the prefab is.

49
00:04:27,740 --> 00:04:36,720
So these spawn point in the assets we will drag and drop that into the registered spoonbill prefab list.

50
00:04:37,630 --> 00:04:44,320
The other thing to take note of at this point is the method at which she applies will be spawned.

51
00:04:44,320 --> 00:04:51,250
Now if you want them to be completely random then you can select random So if you get like 10 spawn

52
00:04:51,250 --> 00:04:57,280
points in your game you don't really have control over where your players will start from.

53
00:04:57,580 --> 00:05:04,540
And it could be purely by random chance that they both start on exactly the same spawn point which in

54
00:05:04,540 --> 00:05:07,390
this case wouldn't be something that we want to happen.

55
00:05:07,390 --> 00:05:15,130
So we've got we're actually working with to play characters and therefore having two separate ones and

56
00:05:15,130 --> 00:05:20,810
making sure that they start on separate locations is more preferrable in this case.

57
00:05:20,830 --> 00:05:24,580
So the spawn method is round robin.

58
00:05:24,940 --> 00:05:29,570
And what that's going to do is put the first people who log in.

59
00:05:29,590 --> 00:05:33,940
On one point and then the next people who are logging on the next point and then the next people on

60
00:05:33,940 --> 00:05:39,820
the next point at siddur until it goes around all of the spawn points and gets back to the first one.

61
00:05:40,000 --> 00:05:48,850
So if you actually have 10 spawn points and 12 people logged into your game then to lots of people will

62
00:05:48,850 --> 00:05:51,840
be overlapping each other spawn point.

63
00:05:51,940 --> 00:05:57,740
In this case we've only got to play characters and we're going to spawn points so that's enough.

64
00:05:57,820 --> 00:06:03,400
So that's all you need to do to set up this starting on different position.

65
00:06:03,400 --> 00:06:06,230
So let's have a look what that's going to work like.

66
00:06:07,280 --> 00:06:10,640
So I've now created a client.

67
00:06:10,790 --> 00:06:14,090
I'll start up the editor to host.

68
00:06:14,360 --> 00:06:23,210
And what you'll notice is that the first car the player character for the server client version spawns

69
00:06:23,270 --> 00:06:26,260
on this point at the top here.

70
00:06:26,660 --> 00:06:32,240
And if we actually draw that Carwile see that it spawned over the top of that spawn point there.

71
00:06:32,420 --> 00:06:41,120
Well you also notice that these two speeches don't appear to stop playing and then run it again before

72
00:06:41,120 --> 00:06:46,230
I've created the network so there's no server running on here whatsoever.

73
00:06:46,460 --> 00:06:47,590
The same might be here.

74
00:06:47,630 --> 00:06:53,000
There's no spawn point you can't see them because there are network objects they don't actually get

75
00:06:53,000 --> 00:07:02,210
instantiated until you've made the network so by clicking on the lane host over here to start the server

76
00:07:02,270 --> 00:07:07,390
and the client it will actually also spawn your spawn points.

77
00:07:07,520 --> 00:07:15,720
Then this one here when we connect the client the second car will start off in the second position.

78
00:07:15,850 --> 00:07:22,480
And that actually fixes the issues that we have before they're all starting in the same point.

79
00:07:22,480 --> 00:07:30,100
So that is how you add spawn points for different locations in your network environment and you can

80
00:07:30,100 --> 00:07:32,860
have them round robin or you can have them random.

