Kicking Ass and Making Games

Primary Menu

Category Dragonspawn

Recently I’ve been reworking the way Projectiles operate in my game to make the mechanics of aiming and shooting feel nicer.

In my game I have two kinds of Projectiles: Hitscan and Missiles. Hitscan Projectiles deal damage to a target immediately using Raycasting whereas Missile Projectiles behave like real world projectiles using velocity and all that fun physics stuff. Beyond that I have a number of parameters that can be modified to alter a Projectile’s behavior, for example a grenade would be configured to use gravity, bounce around and explode after a delay and a rocket would be configured to explode immediately upon impact.

With that out of the way, the issue I actually want to look at is one I’ve encountered with the accuracy of Missile Projectiles. The starting weapon of my game is a simple blaster weapon with infinite ammo that fires small missile projectiles that deal very little damage but they fire with 100% accuracy. This weapon isn’t exactly going to be your go to weapon for the entire game but it’s intended to be there as your last resort if you run out of ammo for all of your other weapons so it at least needs to be reliable, hence the 100% accuracy. The problem is that using Physics to detect collisions gives me sub-optimal, inaccurate results.

The aim model that I’m using first projects a Sphere Cast (basically a thick Raycast) using the current Projectile radius from the main camera until a valid point is hit in world space. From there the contact point is adjusted to give us the actual point that the Projectile needs to fire towards to hit its mark accounting for its radius. Once this is performed the Projectile is then spawned in, given its origin point along with the direction to the target and then it’s fired.

Now the problem…

As we can see here the projectile isn’t hitting its target point, it seems to be overshooting it which is problematic and it looks a bit shit. Now let’s take a quick look at that in slow motion by setting the game’s timescale to 0.1 which will automatically lower the fixed delta time from 0.02 to 0.002 (we’re now essentially just running the game at 10% speed).

Wait a second! Why is it hitting the right spot now? Well technically it isn’t, but it’s a hell of a lot closer to where it needs to be so let’s try it again but back at regular timescale with the fixed delta time set at 0.002 again.

Basically the same results but this is neither a reliable or a viable fix, we’re just running 500 physics cycles per second instead of the default 50, not good.

At this stage I began digging for solutions online but couldn’t find anything beyond changing the fixed delta time which as I’ve already mentioned is not an acceptable solution. The closest thing I found to a fix online was an old community script that prevents fast moving objects from clipping through colliders using Raycasting to catch objects as they clip into something then correcting them. So naturally I tried adapting this to work in my scenario but it didn’t really fix anything. I know at this stage that I’m logically going to have to do something using Raycasting to resolve the problem, I’m too stubborn to just live with my Projectiles being a bit inaccurate.

So, what if I just stripped out the collision stuff and just use the Raycasting? (I later switched to Sphere Casting)

Well I think the results speak for themselves, I feel like this is going to come back to bite me in the bum at some point but at least it’s working as intended.

In retrospect I could have tried using triggers instead of collision which might have improve the accuracy but it doesn’t stop the projectile from overshooting and getting stuck inside of things, and since I already have the Raycasting to check for clipping it just doesn’t make sense to me to have both.

Anyway if you know of a more performant solution or optimizations that’ll get me the same results, or just have questions feel free to leave a comment or shoot me a message.

It’s been a while, thought I should probably post a short update on how things are progressing. At the current time I’m working on a custom AI pathfinding engine, under the hood it’s just using a slightly modified version of the A* Search Algorithm, but I’m combining that with some volumetric data that should allow both ground based and flying enemies to utilize the system properly in a reasonable manner. Once I’ve got some simple pathfinding agents utilizing the system I’ll begin work building an AI that can actually use it to track down the player and attack them which is going to be the fun part. I will probably also release the source code for my pathfinding engine on Bitbucket or GitHub at some point in the future so that others can use or tinker with it.

It’s been a while since my last post, but I wanted to give it some time so that I had some actual stuff to talk about (Image Effects and UI aren’t very interesting on their own). There’s been a number of components and systems that I’ve been working on over the past couple of weeks, the first of those being some simple Post-Processing Effects. Some of the effects likely won’t get utilized on their own but I have been wanting to compile a small library of effects to have as a reference for building more complex effects at a later stage.

The next system that I started building was the framework for handling UI, it’s currently functioning but until I get to doing some actual UI design it’s mostly just a bunch of rogue buttons and text elements for the HUD.

Additionally I’ve also started work on Weapons and Projectiles which are arguably the second most important thing after player movement in a first person shooter. I’m probably trying too hard to make the Projectiles as versatile as possible, but I want to have the option as a designer to make any kind of Projectile be it a missile, grenade or even just a simple hitscan and have them all just work regardless of whether it’s fired by the Player, an enemy Actor or from something in the environment, so for that keeping it largely decoupled from other systems is also important.

Just a minor update, I’ve been working on Player Movement lately, I want to ensure I’ve got a solid implementation that’s pretty much bug free before I move back on to more base game code. Now I say “pretty much bug free” for a reason, the acceleration algorithm I’m using is intentionally bugged to allow for a mechanical exploit known as ‘Strafe Jumping’. I currently have no intentions to make Strafe Jumping a mandatory mechanic for successfully navigating the environment, but I do intend to encourage players to use it to get around faster and to artificially accentuate mayhem in the process.

I’m afraid that’s all for now, I have a couple of weeks off work soon which should give me an opportunity to make a lot of headway with the game over the Christmas/New Year period.

The Software I’m going to be using to develop Dragonspawn is all a matter of personal preference, I’m going to be sticking with what I know well. If you think some piece of software that I’m using is wrong then feel free to go ahead and leave a comment down on some other blog.

The first thing is the Game Engine itself, now I could go and write something from scratch which could be a lot of fun, but for this project I’m going to stick with Unity, I use it for work and have been using it for like a decade now so I know it inside and out. Essentially my plan is to write all of the core systems for Dragonspawn on top of Unity which is there primarily to do all the complex shit like rendering and physics. In terms of Programming Language, I’ll be sticking with C# and not a lot else, I might integrate some of Microsoft’s Gaming APIs like XInput at some point, but I’ll worry about that when it becomes pertinent.

Next thing is the image editing software I’ll be using, which will be Adobe Photoshop CC. I know there’s free alternatives like Gimp, but Photoshop is the one I know so it’s the one I’ll be using.

For 3D Modeling I’ll be renewing my Maya LT license once I need it which won’t be until the game’s core systems are functional. Again, yes, Blender is a free alternative but Maya is just better. There. I said it. Are you happy now?

Last of all is Audio editing software, and I’ll be using a top notch freebie for this one, that being Audacity. I’m not much of an audio guy so it suits my needs, let’s me record, manipulate, and mix sounds, simple.

So currently I’m further into writing the core systems than this blog might suggest, but I’m sure this is eventually going to catch up to where I’m actually at with things.

I keep deliberating and rethinking what I’m going to write for this first post so I might just start with a bit of history and roll into what I’m planning to make.

So about a million (five) years ago before I started working full time I was working on a game called Dragonspawn 2; a sequel to this shit game here. At the time I was unemployed and generally had a lot of spare time between searching for work and sleeping so I was overly ambitious and things got out of hand pretty damn quickly.

To cut a long story short I wasted a lot of time developing useless features like procedural sky and weather systems instead of doing useful stuff like fixing some of the buggy source code pulled from the original game and writing actual integral gameplay systems.

Eventually I found some good full time programming work to help pay the bills, and with that, work on what would have been Dragonspawn 2 tapered off over time. Eventually the pointless features I was working on became side and hobby projects for me. The sky/weather system, colorblind utilities, and even a terrain generation system (what the hell was I gonna do with that anyway?). These all took president over Dragonspawn 2 and it sort of just died a slow uncoordinated death, but it was probably for the best in retrospect. To put it bluntly Dragonspawn 2 was in development hell, it took me a long time to take a step back and realize this, and at that point trying to save the game was impossible.

So I took some time off from it, occupied myself with other things and eventually began writing up a new design document that was heavily critical of the original game as well as the failed sequel. And I’m confident that what I’ve got now in terms of design is a monumental improvement over the original and sticks to a more achievable, concrete set of specs.

So the game I’ll be developing and chronicling on here is just going to be called ‘Dragonspawn’, it’s not a sequel, it’s not a remaster, if anything it’s a reinvention.

I’m still working out how exactly I want this blog to function, my next post will probably be the obligatory one about what software and design practices I’m going to be use/applying to this game’s development and will more than likely outline the exact genre and style in more depth.