Spamocalypse updates: pathfinding, weapon script changes

It’s about time I had a new update. There’s been quite a few changes since the last one, so here goes:

First level redone
For starters, I revamped the starting level, so it no longer uses default shapes and textures. Here’s a screenshot:
SoundTest 30-1-2016 cropped

Added the second level
While I was at it, I added the second level in, and started adding some more detail to it – including some of the buildings I put together for the first level. That one is still a work in progress, and I haven’t tested it entirely. However, I found that I had to disable some of the NPCs, as they were causing performance drops. So, I added in a portal that enables or disables specific moving objects depending on where you are. It’s trigger based, so it occurs once, but there’s probably still going to be some performance issues I haven’t noticed yet.

Pathfinding updates

The pathfinding system now takes directional and area lights into account when calculating light intensity. As before, it involves raycasts while I’m building the mesh, so I split the mesh building into separate tasks for calculating positions, calculating illumination and saving to the mesh. However, I am considering rewriting it so that the navigation mesh I built is stored as a ScriptableObject instead of being serialised to the disk. This would allow me to drag-and-drop the mesh into the pathfinding script, and therefore have it preloaded by Unity.

Refactored the weapon script
I originally had one weapon type, which was hitscan-based. That weapon script is now the base class for all weapon types, and the others simply override the attack method, as follows:

  • Projectile weapons retrieve a piece of ammo from a shared pool, and launch it in a particular direction with a specific velocity
  • Melee weapons are collider-based, and are triggered by an animation for the attacker.
  • Hitscan weapons cast a sphere with a particular radius in a particular direction

The levels now have maps. Each looks like a sheath of parchment, like in Thief. The second level has two maps, because I just couldn’t fit it onto one. Most of these are screenshots of the level from Unity or Blender, with the edges found using a Sobel filter in GIMP.

Changes to Interaction system
I simplified the player interaction system a bit. It was previously build around checking if the player was looking at one specific object. It’s now set to check if the player is looking at any child object, which should give the player a bit more room to use them.

32-bit Linux is no longer supported
From now on, I am assuming a 64-bit operating system. I was previously creating both 32-bit and 64-bit Linux builds, as Unity does give an option to create a universal build. However, that creates two separate executables at the same time. To do this in the Windows build, I’d have to change the platform to 32-bit Windows, build it, then switch to 64-bit Windows and build it again. Frankly, I don’t think it’s worth it.

Spamocalypse 1.6 – Linux Build

The title says it all – I now have a Linux release for Spamocalypse!

This is pretty much my first ever Linux build, so it is buggy. I’ve noticed that the mouse position is consistently lower than the cursor position. I’ve added a workaround, which is to make controls a bright orange colour when they’re highlighted, instead of the default off-grey – if this is a problem for anyone who’s colour-blind, please let me know. Another issue is the same limited mouse rotation that I’ve been having in the Editor – I added arrow key rotation to get around that, but the rotation speed is hard-coded and quite slow.

In other news, I’ve set the main menu to use part of the geometry from the City Inbound level. Here’s a screenshot:

A screenshot of the main menu scene. A little too dark, perhaps?
A screenshot of the main menu scene. A little too dark, perhaps?

City Inbound itself is coming along – a stormy weekend in Ireland is the perfect time to sit down and do this sort of thing – but it’s not complete yet. I ran into problems baking the lighting, so I’ve had to adjust my workflow. Firstly, most of the buildings are split into separate parts: an outer shell, and inner sections for each room. This might actually benefit me when I’m baking occlusion culling into the levels, as it means hiding smaller objects that the player can’t see rather than one big object. I also found that if I lowered the resolution of the lightmaps, it sped things up massively.

Unity Linux Editor

I’ve been using the Linux Editor for Unity3D for a few weeks now, and I’ve run into some odd bugs while doing so.

The first one is that mouse rotation has a very limited range – it’s basically limited to the screen size, which limits it to about a 90 degree field of rotation. This occurs in the Linux builds as well. There is a workaround, which is to recentre the mouse (i.e. when paused), but that’s pretty tedious.

I started working on a workaround for that, which is to use the arrow keys to rotate. As far as I remember, System Shock 2, Thief and Thief 2 allowed this as well, so that’s another reason for doing so. It works perfectly fine in the build, but not quite in the editor. What appears to happen is that the up and down keys cause the game tab to lose focus. And I’m not the only person who’s run into that.

Finally, I had a massive drop in framerate for no apparent reason. Even an empty scene got a massive hit of less than 40-50 FPS. However, this wasn’t an editor problem, but a graphics driver problem: my graphics card was using version 1:7.3.0-1ubuntu3.1 of the recommended X.Org X Server driver, but when I changed it to use the fglrx-updates driver and restarted, it worked absolutely fine. If you’re using an AMD/ATI graphics card and having a similar problem, give that a try.

There are also some minor issues such as the contents of a UI Text disappearing after losing and regaining focus (see the below images), but that is purely cosmetic, and the text reappears after you do anything like select the text in the hierarchy, or tweak something in the inspector if you have it already selected.

Finally, Application.persistentDataPath returns null in both editor and build, which is causing an issue with saving data. However, Application.dataPath and Application.persistentDataPath do work, so I have a workaround for this.

So far, however, it generally works.

I have a new computer

Finally, I have a new computer for development instead of the broken down laptop I’ve been using for 3 1/2 years now. Well, I built most of it about a month ago. I ordered the parts via dabs, and they all arrived while I was at work. Bit of an issue there, but it worked out.

Actually putting the computer together was…somewhat frightening. This is the first computer I’ve built, so I kept expecting it to fall apart at any moment, and yet it worked – with the exception of the sound card I bought (an ASUS XONAR D-Kara, which I was planning to use for voice recording). That isn’t supported on Linux, but the chipset on which it is based is, according to this site. However, the main reason why sound wasn’t working is that I didn’t have any speakers! Now that I do, pulseaudio seems to do the trick perfectly fine.

The parts that I’m using are as follows:

  • 8 GB of RAM
  • MSI Radeon R7 graphics card, with 1GB of dedicated memory. For comparison, my laptop’s graphics card a built-in card which shares memory with the RAM, and uses between 64MB and 1GB of RAM.
  • ASUS M5A97 motherboard
  • AMD FX-6300 CPU, with 6 cores
  • D-Link DGE-528T Ethernet card. Yes, Ethernet. I didn’t get a WiFi adapter, but Ethernet is faster and more reliable.
  • HannsG monitor. This was second-hand, saving me €25. Unfortunately, it had no speakers.
  • ASUS XONAR D-Kara sound card. This does not work with Linux, so it’s redundant to me (and cost me just over €50!)
  • Corsair CX 430 power supply unit. Supplies up to 430W.
  • LiteOn IHAS124-14 CD/DVD drive.
  • Logitech keyboard, UK layout (couldn’t find an Irish one 😦 )
  • Logitech z130 speakers
  • Linux Mint 17.2

Total cost: €727. Knowing I can build and upgrade my own machine: Priceless.

So far, it’s working fine. The Linux Editor for Unity installed and worked fine, and I have just tested Spamocalypse on it (and found some bugs). So, very soon I will start to support Linux builds. In the meantime, I’m starting to do my 3D modelling on the new machine, and keep using the version of Unity that’s on my laptop for Spamocalypse.