These Weird Optimizations Made Our Game Run 10x FASTER! — Transcript
Full transcript
- 0:00So, what you're seeing on the screen
- 0:01right now is roughly 1,400 bullets being
- 0:05fired every second with the game running
- 0:08at 60 frames per second. No stuttering
- 0:10and no lag spikes. But how?
- 0:14Hey guys. So, me and my team are making
- 0:17a physics-based FPS game. And in this
- 0:19video, I'm going to talk about all the
- 0:21various tricks and methods we used to
- 0:24take our game from running like a
- 0:25PowerPoint presentation to a buttery
- 0:27smooth performance. So our game is
- 0:30simply chaotic. There is a lot of moving
- 0:32objects, enemies left and right, and
- 0:34explosions everywhere. So for our game
- 0:37to handle all of this, optimization was
- 0:40a number one priority. However, the one
- 0:42thing we refuse to cut down on is
- 0:45projectiles, and there is a lot of them.
- 0:47In many games, like for example,
- 0:49Counterstrike, Left 4 Dead, Team
- 0:51Fortress 2, or GTA games all have quote
- 0:54unquote real weapons. In real life, most
- 0:57weapons fire so fast, you can't even see
- 1:00the bullets being fired. Now, why is
- 1:02this important? Well, because you cannot
- 1:04see the bullet, developers often don't
- 1:06bother simulating them to save
- 1:08performance. In such games, the moment
- 1:10you fire a weapon, you instantly hit a
- 1:13target. This is often called hit scan
- 1:15projectile, and in most cases, it works
- 1:17great, but this only works if the
- 1:19projectiles are completely invisible.
- 1:22Our game is set in a sci-fi world and
- 1:24when you have a weapon that's literally
- 1:25called plasma gun, you kind of expect to
- 1:28see something like this. So if our game
- 1:30cannot use heat scan projectiles, how do
- 1:32we deal with this? Well, one option is
- 1:35to treat each projectile as a physical
- 1:37object that is created each time you
- 1:39fire a weapon. This is actually how our
- 1:42game handled projectiles at first. And
- 1:44honestly, it worked great. Or at least
- 1:47it seemed like it. When I started
- 1:48testing the game, it ran at like 15
- 1:51frames per second. And all of this is
- 1:53because of something called
- 1:56basically our game is multiplayer and
- 1:58every single one of those bullets had to
- 2:01be sent over the network for other
- 2:03players to see. But when there is
- 2:05hundreds of bullets constantly being
- 2:07sent, it completely tanks the
- 2:08performance of the whole game. This is
- 2:11thanks to something called network
- 2:12bandwidth. To put it simply, network
- 2:15bandwidth is kind of like a door into a
- 2:17building. If someone wants to get into
- 2:18the building, they must first go through
- 2:20the door. But if there is too many
- 2:22people trying to go through the same
- 2:24door, it will create blockages. In our
- 2:27game, bullets were like those people
- 2:29trying to go through the door. The
- 2:30problem is there was way too many of
- 2:33them. So, how did we solve this issue?
- 2:35How did we go from our game barely
- 2:37clinging to life to being able to handle
- 2:39thousands of projectiles with no
- 2:41problems? Well, I live by the words,
- 2:44fake it if you can't make it. All those
- 2:46bullets you see, yeah, they're
- 2:48completely fake. Now, before you start
- 2:50saying how disappointed you are, trust
- 2:51me, it's for the better. When you fire a
- 2:53weapon, you can still see bullets being
- 2:55fired. Only these bullets are purely
- 2:58visual. They don't do anything. The real
- 3:00magic happens on the server. The server
- 3:02doesn't treat bullets like physical
- 3:04objects. Instead, it simulates them. If
- 3:07you think about it, all you need to know
- 3:08is the starting position, direction, and
- 3:11velocity of a bullet, and you can
- 3:13accurately predict where a bullet will
- 3:15be at a certain time. Basically, we've
- 3:17reduced a whole object into just few
- 3:20numbers. That's the reason why this
- 3:22approach is lightning fast and causes
- 3:25little to no performance heat.
- 3:29Now, bullets were only one of the things
- 3:32that needed to be optimized to run fast.
- 3:34But there was a bigger issue. Grenades.
- 3:37At first, the way grenades worked in our
- 3:40game was pretty standard. You pick up a
- 3:42grenade, you throw it, this creates a
- 3:44physical object in the world with
- 3:46momentum and velocity, and then they
- 3:48explode. I never tried optimizing
- 3:50grenades that much because I knew
- 3:52there's never going to be a situation
- 3:54where there are too many of them in the
- 3:56world at the same time. Well, that all
- 3:59changed when we added this enemy into
- 4:01our game. This enemy is called
- 4:03Striderbot. And one of his attacks is
- 4:06throwing grenades. Except he doesn't
- 4:08throw one. No, he throws four every
- 4:11second. That's a lot. Even more when
- 4:14there is like two or three of them at
- 4:17the same time. So, what did we do? I
- 4:20tried using the same logic we used for
- 4:22projectiles to simulate their movement
- 4:24using math. The problem is projectiles
- 4:26are linear. Grenades are not. They can
- 4:29bounce off floors, walls, or anything in
- 4:32any direction, which makes them very
- 4:34unpredictable. So, we needed something
- 4:36more sophisticated. Fortunately, with a
- 4:39quick Google search, I found that all I
- 4:41need is this simple equation. To put it
- 4:44simply, this allows us to get a position
- 4:46of an object at any time, which is
- 4:49exactly what I was looking for. Of
- 4:51course, actually implementing this into
- 4:53our game was a bit more difficult, and I
- 4:56ran into a few problems. But eventually,
- 4:58I got it working perfectly, and now we
- 5:01can even have a whole fountain of
- 5:03grenades with no performance issues. By
- 5:06the way, this took a long time to make,
- 5:07so please subscribe. Anyway, pretty much
- 5:10everything works flawlessly now, except
- 5:13one thing.
- 5:18Since we started working on the game,
- 5:20enemies had many problems, but one
- 5:22problem was persistent turrets. Every
- 5:25enemy in our game has them, and it's
- 5:27what they use to attack players.
- 5:29However, to target players, they need to
- 5:31rotate to face them. And this simple act
- 5:34of rotation is what caused huge
- 5:37performance issues. They would often
- 5:38take half of the available network
- 5:41bandwidth, and I'm talking purely just
- 5:43turrets.
- 5:44At first, I tried rotating threats
- 5:47through a script, but using C frames is
- 5:49too expensive. I tried using animation
- 5:51rigs, also too expensive. I tried using
- 5:54a few mechanical constraints, too
- 5:56expensive. I even tried using things
- 5:58like a line orientation, but no. At this
- 6:01point, I started to realize I was
- 6:03running out of options. I was looking
- 6:05for a solution that would allow me to
- 6:07have many turrets with minimal
- 6:08performance hit, but none seemed to
- 6:11work. But then out of nowhere, I had a
- 6:14light bulb moment. Instead of running
- 6:16the turret logic on the server, why not
- 6:19run the logic locally and have players
- 6:21do the work and then the server would
- 6:23just try to estimate where the touret is
- 6:25looking. Even though this solution
- 6:27wasn't ideal, it solved everything kind
- 6:30of the performance hit was now minimal,
- 6:32but if you remember, I said the word
- 6:34estimate since the turret logic was in
- 6:37the hands of the players. Now, the
- 6:38server didn't have the most up-to-date
- 6:41information, which means the server
- 6:43could only guess where to fire a
- 6:45projectile, and it wasn't synced with
- 6:47the rotation. This sometimes resulted in
- 6:49situations like this where you can see
- 6:51the turret is facing a completely wrong
- 6:54direction. This wasn't great, but
- 6:56unfortunately, I didn't have another
- 6:58option. So, this is how turrets worked
- 7:01for a long time. But then, out of
- 7:04nowhere, a perfect solution emerged.
- 7:08In Roblox, there is something called IK
- 7:10control. It's what allows you to easily
- 7:12make procedural animations on your
- 7:14characters. Our game uses this a lot.
- 7:17But what I haven't noticed before is
- 7:19that one of the modes on the IK control
- 7:22is called look at, which rotates a part
- 7:25to face a target. When I found this out,
- 7:28I immediately started testing this. And
- 7:30to my surprise, not only does it work
- 7:33exactly how I want it, but it also
- 7:35causes no performance issues. Like all
- 7:38of this runs on the server, by the way.
- 7:40All of this is real. Nothing is fake. If
- 7:43I had known this earlier, this would
- 7:45have saved me so much time. Well, I
- 7:48mean, if there is anyone watching this
- 7:50video that wants to make a lot of
- 7:52tourets, I guess this is how you do it.
- 7:54Now, just to clarify, there are more
- 7:56optimizations we did, especially with
- 7:59the enemies and how they work, but
- 8:01that's for another video. Also, if you'd
- 8:03like to know more about the game we're
- 8:05working on, you can click this video
- 8:07here. Trust me, you'll love it. Anyways,
- 8:10that's all. Thanks for watching and see
- 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.