Sprinting Up That Hill

I’ve slowly but surely been making additions to one of my older projects – my first-person project initially inspired by immersive sims. Throughout the past few months, I’ve continued to piece together elements of combat and the player’s verbs, while also reevaluating some of my existing work. Spoiler alert: I broke something.

I wanted to start with a system to let the player move faster; in shooters, sprinting is often a trade-off, giving players increased speed at the cost of their ability to fire their weapons. I considered this decision but opted to go a different direction. Why? In truth I don’t know what this game is going to be – I want to try things, see what’s fun, and attempt to build something from the initially disparate parts. (As a one-woman dev team with no stakeholders or deadlines, I have the flexibility that allows for this kind of process. Whether it’ll result in a functional game remains to be seen.)

So, I’m trying something new. I want players to be able to shoot and sprint at the same time, but I don’t necessarily want it to be easy. Rather than a traditional hold or toggle sprint, I have a system that demands a bit more of the player’s attention. I took shameless inspiration from Limasse Five’s Naissance (it’s free and quite good, go check it out) in this regard. While that game focuses primarily on navigation and quick movement, I wanted to try pairing a similar system with shooter mechanics. Here’s the rough implementation:

 The player character can functionally sprint forever, as well as shoot and reload while doing so, as long as they’re moving forwards and they re-press the sprint button at the right time. Too fast or too slow and they’ll be forced to stop. Ideally, it’s easy – until the player is faced with a hail of gunfire or the need to aim at distant enemies. This is a weird kind of rhythm challenge I haven’t seen in too many games before, and I wanted to give it a try.

I’ve also been adding to the player’s arsenal, slowly. I’m grateful to my past self for implementing my gun script like I did – I future-proofed it by leaving plenty of exposed variables which I can use to easily make new weapons. Attributes like magazine size, reload timers, the number of projectiles fired, and more are all incredibly simple to adjust.

What was less easy was creating weapon spread. I’d already had a simple system that modifies a bullet’s accuracy if the player didn’t pace their shots; presumably, I could apply the same code to every shot in a burst to create a shotgun-like effect. I’d get some inconsistently messy spread, but I could always add more parameters later. The simple solution worked – until I realized that my spread patterns were weirdly vertical sometimes, and incredibly vertical other times. A perfectly vertical line of bullets. I wish I had images of this to share here.

Something clearly wasn’t randomizing correctly. In fact, this issue affected my older accuracy system as well – I just hadn’t tested it thoroughly enough to realize. Turns out, I was modifying a transform along two axes to randomize each bullet’s trajectory, and those axes didn’t rotate as the player did. Bullets would randomize correctly if the player was aligned with the z axis and ‘randomize’ perfectly vertically if they were aligned with the x axis; anywhere between would trend vertically, too.

This took an embarrassingly long time to figure out, but the fix was easy – rather than passing a transform to my hitscan raycast generation, I had to semi-randomize a rotation and pass that in instead. I could conveniently use the same transform that the raycast originated from, and that was that. Now, my weapon spread and accuracy work great!

 I’ve thrown a few little bits of visual flair in, too – most notably, a highlight and button prompt whenever the player looks at an interactable object. It’s simple, readable and adds a ton of clarity. There’s also an ammo tracker now!

So, what did I break? This one’s a doozy – the entire enemy navigation system. My wonderfully janky code that once had enemies diving for cover and frantically shooting around corners (okay, it wasn’t that dramatic) has somehow turned into sad little drones that can’t even turn to face their targets. They still try to shoot the player, though, which is hilarious – they’ll even shoot themselves in the process. I’m investigating what might have caused this problem, but I’m not throwing all of my time into it – as relevant as it is, I want to be able to keep moving forward. I’ll revisit the AI another day.

Previous
Previous

Finding My Drive

Next
Next

Something Old, Something New