-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog_towerdefence.html
232 lines (195 loc) · 8.11 KB
/
blog_towerdefence.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html lang="en">
<head>
<!-- meta -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Joshua Mobley - Personal Portfolio</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-QPWGYQJDTC"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-QPWGYQJDTC');
</script>
<!-- tab img -->
<link rel="icon" href="assets/img/favicon.ico" type="image/x-icon">
<!-- css plugin -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/magnific-popup.css">
<link rel="stylesheet" href="assets/css/flexslider.css">
<link rel="stylesheet" href="assets/css/aos.css">
<!-- main css -->
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/style-responsives.css">
<!-- google fonts -->
<link href="https://fonts.googleapis.com/css?family=Hind:600|Lato:300,400" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- // PRELOADER BEGIN -->
<div id="preloader">
<div id="status">
<div class="loader-revolve center">
<span></span>
</div>
</div>
</div>
<!-- // PRELOADER END -->
<!-- // NAVIGATION BEGIN -->
<div id="navigation">
<div class="container">
<div class="col-sm-3">
<div class="logo">
<a href="index.html">Joshua Mobley.</a>
</div>
</div>
<div class="col-sm-9">
<div class="navigation-menu">
<div class="navbar">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a class="smoth-scroll" href="index.html#blog">Back</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- // NAVIGATION END -->
<!-- // HEADER BEGIN -->
<div id="header" class="home-bg" style="background-image: url('assets/img/portfolio/portfolio-0.jpg')">
<div class="overlay-blog">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="post-heading text-center">
<h1 class="f-white">Conclusion on Tower Defence Project</h1>
<span class="meta">Posted by
<a target="_blank" href="https://twitter.com/deadmonstors">Josh Mobley</a> on November 09 2020
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- // HEADER END -->5
<!-- // POST BEGIN -->
<section id="post">
<div class="container">
<div class="row">
<div class="post-container">
<h2 class="post-title">Introduction on Tower Defence Project:</h2>
This is my first university project within second year. It had to be a tower defence game that we wanted to create. <br>
I chose to make a Online CO-OP Tower Defence game where you could help each other to defend against the military that is trying to attack you.<br>
The theme is military I picked a simplistic style as that is what I was most tower defenses go and it looked good.<br><br>
Latest video:
<br><iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/YPYEVccUKag?controls=1" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<br><br>Multiplayer show off:
<br><iframe width="560" height="315" src="https://www.youtube.com/embed/R_sFwsqeBqQ" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<br><br><br><br><h2>Things I learnt within this project:</h2>
<h3>Networking:</h3>
For networking I was using <a target="_blank" href="https://mirror-networking.com/">Mirror Networking</a>
which is an Networking API that goes over the top of Unity's UNet system to make it better/easier for
developers to implement it.
<br><br>
This is the code for syncing an variable between all clients.
<pre><code>[SyncVar]
int test = 0;
</code></pre>
This code allow you to fire a callback whenever this updates on *any* clients
<pre><code>[SyncVar=(hook = nameof(setTest))]
int test = 0;
void setTest(int oldTest, int newTest)
{
// Do stuff here.
}
</code></pre>
This made it very easy for me to be able to network variables however you have to make sure that
you account for that value not being synced if you join the game after it is called.
<br><br>
Networking between Client -> Server needed a Command think of this like a message telling the server what to do.
Some of these messages needed authority to work on certain objects so that people cannot control the wrong person
<pre><code>[Command]
public void CmdSetDoorState(DoorState newDoorState, NetworkConnectionToClient sender = null)
{
if (sender.identity.GetComponent<Player>().hasDoorKey)
doorState = newDoorState;
}
</code></pre>
<br>This code will allow only the owner of the door to open the door. Something like this has to have a specific hierarchy or a function called on it so that you can "give" it auth.
Another way is to tell the command to ignore who the owner is.
<pre><code>[Command(ignoreAuthority = true)]
</code></pre>
<br>This required me to do the hierarchy like this so that everyone objects under the player gets the auth to control itself.
<img src="https://i.imgur.com/vHbfAka.png">
<br><br><br>
<h4>Other blogs about this project:</h4>
<div class="col-md-4 col-sm-6 text-center">
<div class="blog-item">
<a href="blog_01.html" class="blog-img">
<img src="assets/img/portfolio/portfolio-0.jpg">
</a>
<div class="blog-desc">
<h4>
<a href="blog_01.html">Object Pooling</a>
</h4>
<p>The issues with using Object Pooling in a fully multiplayer game.</p>
<a href="blog_01.html" class="btn btn-dark">Read more</a>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- // POST END -->
<!-- // FOOTER BEGIN -->
<footer id="footer-post">
<div class="container">
<div class="col-md-8 col-md-offset-2 text-center">
<ul class="social-icons-footer">
<li><a target="_blank" href="https://www.linkedin.com/in/joshua-mobley/"><i class="fa fa-linkedin"></i></a></li>
<li><a target="_blank" href="https://twitter.com/deadmonstors"><i class="fa fa-twitter"></i></a></li>
<li><a target="_blank" href="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/deadmonstor"><i class="fa fa-github"></i></a></li>
<li><a target="_blank" href="https://steamcommunity.com/id/deadmonstor"><i class="fa fa-steam"></i></a></li>
</ul>
<p>© 2023 Joshua Mobley</p>
</div>
</div>
</footer>
<!-- // FOOTER END -->
<!-- js plugin -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.stellar.min.js"></script>
<script src="assets/js/text-rotate.js"></script>
<script src="assets/js/numscroller.js"></script>
<script src="assets/js/jquery.appear.js"></script>
<script src="assets/js/progress-bar.min.js"></script>
<script src="assets/js/jquery.mixitup.js"></script>
<script src="assets/js/jquery.magnific-popup.min.js"></script>
<script src="assets/js/magnific-popup-options.js"></script>
<script src="assets/js/jquery.flexslider-min.js"></script>
<script src="assets/js/aos.js"></script>
<script src="assets/js/app.js"></script>
<!-- main js -->
<script src="assets/js/main.js"></script>
</body>
</html>