YouTube2Text

These Weird Optimizations Made Our Game Run 10x FASTER! — Transcript

by Roox4 · 1,443 words · 212 segments · language en · Watch on YouTube

Full transcript

  1. 0:00So, what you're seeing on the screen
  2. 0:01right now is roughly 1,400 bullets being
  3. 0:05fired every second with the game running
  4. 0:08at 60 frames per second. No stuttering
  5. 0:10and no lag spikes. But how?
  6. 0:14Hey guys. So, me and my team are making
  7. 0:17a physics-based FPS game. And in this
  8. 0:19video, I'm going to talk about all the
  9. 0:21various tricks and methods we used to
  10. 0:24take our game from running like a
  11. 0:25PowerPoint presentation to a buttery
  12. 0:27smooth performance. So our game is
  13. 0:30simply chaotic. There is a lot of moving
  14. 0:32objects, enemies left and right, and
  15. 0:34explosions everywhere. So for our game
  16. 0:37to handle all of this, optimization was
  17. 0:40a number one priority. However, the one
  18. 0:42thing we refuse to cut down on is
  19. 0:45projectiles, and there is a lot of them.
  20. 0:47In many games, like for example,
  21. 0:49Counterstrike, Left 4 Dead, Team
  22. 0:51Fortress 2, or GTA games all have quote
  23. 0:54unquote real weapons. In real life, most
  24. 0:57weapons fire so fast, you can't even see
  25. 1:00the bullets being fired. Now, why is
  26. 1:02this important? Well, because you cannot
  27. 1:04see the bullet, developers often don't
  28. 1:06bother simulating them to save
  29. 1:08performance. In such games, the moment
  30. 1:10you fire a weapon, you instantly hit a
  31. 1:13target. This is often called hit scan
  32. 1:15projectile, and in most cases, it works
  33. 1:17great, but this only works if the
  34. 1:19projectiles are completely invisible.
  35. 1:22Our game is set in a sci-fi world and
  36. 1:24when you have a weapon that's literally
  37. 1:25called plasma gun, you kind of expect to
  38. 1:28see something like this. So if our game
  39. 1:30cannot use heat scan projectiles, how do
  40. 1:32we deal with this? Well, one option is
  41. 1:35to treat each projectile as a physical
  42. 1:37object that is created each time you
  43. 1:39fire a weapon. This is actually how our
  44. 1:42game handled projectiles at first. And
  45. 1:44honestly, it worked great. Or at least
  46. 1:47it seemed like it. When I started
  47. 1:48testing the game, it ran at like 15
  48. 1:51frames per second. And all of this is
  49. 1:53because of something called
  50. 1:56basically our game is multiplayer and
  51. 1:58every single one of those bullets had to
  52. 2:01be sent over the network for other
  53. 2:03players to see. But when there is
  54. 2:05hundreds of bullets constantly being
  55. 2:07sent, it completely tanks the
  56. 2:08performance of the whole game. This is
  57. 2:11thanks to something called network
  58. 2:12bandwidth. To put it simply, network
  59. 2:15bandwidth is kind of like a door into a
  60. 2:17building. If someone wants to get into
  61. 2:18the building, they must first go through
  62. 2:20the door. But if there is too many
  63. 2:22people trying to go through the same
  64. 2:24door, it will create blockages. In our
  65. 2:27game, bullets were like those people
  66. 2:29trying to go through the door. The
  67. 2:30problem is there was way too many of
  68. 2:33them. So, how did we solve this issue?
  69. 2:35How did we go from our game barely
  70. 2:37clinging to life to being able to handle
  71. 2:39thousands of projectiles with no
  72. 2:41problems? Well, I live by the words,
  73. 2:44fake it if you can't make it. All those
  74. 2:46bullets you see, yeah, they're
  75. 2:48completely fake. Now, before you start
  76. 2:50saying how disappointed you are, trust
  77. 2:51me, it's for the better. When you fire a
  78. 2:53weapon, you can still see bullets being
  79. 2:55fired. Only these bullets are purely
  80. 2:58visual. They don't do anything. The real
  81. 3:00magic happens on the server. The server
  82. 3:02doesn't treat bullets like physical
  83. 3:04objects. Instead, it simulates them. If
  84. 3:07you think about it, all you need to know
  85. 3:08is the starting position, direction, and
  86. 3:11velocity of a bullet, and you can
  87. 3:13accurately predict where a bullet will
  88. 3:15be at a certain time. Basically, we've
  89. 3:17reduced a whole object into just few
  90. 3:20numbers. That's the reason why this
  91. 3:22approach is lightning fast and causes
  92. 3:25little to no performance heat.
  93. 3:29Now, bullets were only one of the things
  94. 3:32that needed to be optimized to run fast.
  95. 3:34But there was a bigger issue. Grenades.
  96. 3:37At first, the way grenades worked in our
  97. 3:40game was pretty standard. You pick up a
  98. 3:42grenade, you throw it, this creates a
  99. 3:44physical object in the world with
  100. 3:46momentum and velocity, and then they
  101. 3:48explode. I never tried optimizing
  102. 3:50grenades that much because I knew
  103. 3:52there's never going to be a situation
  104. 3:54where there are too many of them in the
  105. 3:56world at the same time. Well, that all
  106. 3:59changed when we added this enemy into
  107. 4:01our game. This enemy is called
  108. 4:03Striderbot. And one of his attacks is
  109. 4:06throwing grenades. Except he doesn't
  110. 4:08throw one. No, he throws four every
  111. 4:11second. That's a lot. Even more when
  112. 4:14there is like two or three of them at
  113. 4:17the same time. So, what did we do? I
  114. 4:20tried using the same logic we used for
  115. 4:22projectiles to simulate their movement
  116. 4:24using math. The problem is projectiles
  117. 4:26are linear. Grenades are not. They can
  118. 4:29bounce off floors, walls, or anything in
  119. 4:32any direction, which makes them very
  120. 4:34unpredictable. So, we needed something
  121. 4:36more sophisticated. Fortunately, with a
  122. 4:39quick Google search, I found that all I
  123. 4:41need is this simple equation. To put it
  124. 4:44simply, this allows us to get a position
  125. 4:46of an object at any time, which is
  126. 4:49exactly what I was looking for. Of
  127. 4:51course, actually implementing this into
  128. 4:53our game was a bit more difficult, and I
  129. 4:56ran into a few problems. But eventually,
  130. 4:58I got it working perfectly, and now we
  131. 5:01can even have a whole fountain of
  132. 5:03grenades with no performance issues. By
  133. 5:06the way, this took a long time to make,
  134. 5:07so please subscribe. Anyway, pretty much
  135. 5:10everything works flawlessly now, except
  136. 5:13one thing.
  137. 5:18Since we started working on the game,
  138. 5:20enemies had many problems, but one
  139. 5:22problem was persistent turrets. Every
  140. 5:25enemy in our game has them, and it's
  141. 5:27what they use to attack players.
  142. 5:29However, to target players, they need to
  143. 5:31rotate to face them. And this simple act
  144. 5:34of rotation is what caused huge
  145. 5:37performance issues. They would often
  146. 5:38take half of the available network
  147. 5:41bandwidth, and I'm talking purely just
  148. 5:43turrets.
  149. 5:44At first, I tried rotating threats
  150. 5:47through a script, but using C frames is
  151. 5:49too expensive. I tried using animation
  152. 5:51rigs, also too expensive. I tried using
  153. 5:54a few mechanical constraints, too
  154. 5:56expensive. I even tried using things
  155. 5:58like a line orientation, but no. At this
  156. 6:01point, I started to realize I was
  157. 6:03running out of options. I was looking
  158. 6:05for a solution that would allow me to
  159. 6:07have many turrets with minimal
  160. 6:08performance hit, but none seemed to
  161. 6:11work. But then out of nowhere, I had a
  162. 6:14light bulb moment. Instead of running
  163. 6:16the turret logic on the server, why not
  164. 6:19run the logic locally and have players
  165. 6:21do the work and then the server would
  166. 6:23just try to estimate where the touret is
  167. 6:25looking. Even though this solution
  168. 6:27wasn't ideal, it solved everything kind
  169. 6:30of the performance hit was now minimal,
  170. 6:32but if you remember, I said the word
  171. 6:34estimate since the turret logic was in
  172. 6:37the hands of the players. Now, the
  173. 6:38server didn't have the most up-to-date
  174. 6:41information, which means the server
  175. 6:43could only guess where to fire a
  176. 6:45projectile, and it wasn't synced with
  177. 6:47the rotation. This sometimes resulted in
  178. 6:49situations like this where you can see
  179. 6:51the turret is facing a completely wrong
  180. 6:54direction. This wasn't great, but
  181. 6:56unfortunately, I didn't have another
  182. 6:58option. So, this is how turrets worked
  183. 7:01for a long time. But then, out of
  184. 7:04nowhere, a perfect solution emerged.
  185. 7:08In Roblox, there is something called IK
  186. 7:10control. It's what allows you to easily
  187. 7:12make procedural animations on your
  188. 7:14characters. Our game uses this a lot.
  189. 7:17But what I haven't noticed before is
  190. 7:19that one of the modes on the IK control
  191. 7:22is called look at, which rotates a part
  192. 7:25to face a target. When I found this out,
  193. 7:28I immediately started testing this. And
  194. 7:30to my surprise, not only does it work
  195. 7:33exactly how I want it, but it also
  196. 7:35causes no performance issues. Like all
  197. 7:38of this runs on the server, by the way.
  198. 7:40All of this is real. Nothing is fake. If
  199. 7:43I had known this earlier, this would
  200. 7:45have saved me so much time. Well, I
  201. 7:48mean, if there is anyone watching this
  202. 7:50video that wants to make a lot of
  203. 7:52tourets, I guess this is how you do it.
  204. 7:54Now, just to clarify, there are more
  205. 7:56optimizations we did, especially with
  206. 7:59the enemies and how they work, but
  207. 8:01that's for another video. Also, if you'd
  208. 8:03like to know more about the game we're
  209. 8:05working on, you can click this video
  210. 8:07here. Trust me, you'll love it. Anyways,
  211. 8:10that's all. Thanks for watching and see
  212. 8:12you next time.

About this transcript

This page contains the full transcript of These Weird Optimizations Made Our Game Run 10x FASTER! by Roox4, generated from the public captions YouTube serves with the video. The transcript has 1,443 words across 212 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.