Devblog 143

Nicer junk, further optimisation, loot table fixes, and more.

12 January 2017
Cost Changes

The wood armor was never supposed to need cloth after we added the rope item. This is now fixed and it should be easier to craft. I’ve also drastically reduced the cost of water buckets, as you’ll need them for...

Farming 1.5

I’ve reworked a bunch of the farming mechanics. It may not seem like a priority, but I’m trying to get old forgotten features ship-shape and ready for prime time.

You’re not forced to do anything differently: if you really want to you can spam lines of hemp/pumpkins outside and it’ll grow just like it used to. However, if you have a green thumb, you can take care of your plants by placing them in a planter (2x growth speed) and give them light 24 hours a day via the ceiling light (2x growth speed), and if you pour fresh water into the planter you’ll notice the soil gets darker (temp effect). As the plants grow they will consume this water. Given enough water over its lifetime, the yield of the plant can double! Salt water, however, will completely dry them out. It’s not complete, we need more artwork and shader features, and I’d like to do a genetics thing where you can clone good plants or extract high quality seeds, but it’s a good enough start. Enjoy!

p.s. to any server owners: if there are performance issues with the light calculation, you can disable it with plantlightdetection = false and they will instead calculate light exposure based on time of day

New Loot Crates + Changes

I was resistant to adding full items spawning as I felt it bypassed the component system, but enough people internally and externally expressed their desire for it, so we’re going to run an experiment. I’ve added a new, purple (temp art) loot crate which spawns at junk piles. It can contain hatchets, pickaxes, starter weapons, and some armor. I figure we should start with baby steps and see how it is received. I’ve also changed the probabilities of crates for all the different junkpiles. You’re more likely to find the purple loot crates near cars/trucks, the smaller junkpiles are more likely to have food and oil, and the machinery style ones are more likely to have tier2 components.

Ceiling Lights

I increased the brightness of ceiling lights by 50% during my work on farming. I was hesitant to do this because we can’t afford to add shadows to them, which means there is a larger chance of light bleed through walls. I tried to find a middle-ground, so let’s see how this turns out. One thing is for sure, your bases and/or grow ops will be much brighter!

Corpse Flies

Flies at night were using an unlit shader, which meant they were visible even though it was pitch black. This is now fixed.

Junkpile Variants

This week I spent some time remodelling two of our vehicles into wrecks to make more junk pile variants. I also put together several other piles to add variation. The way these spawn on the terrain for now is not perfect, some adjustments remain to be made in that territory.

Truck Variants

This week I focused on finishing the additional truck variants that were shown in an update a couple of weeks ago, as well as some minor polish on the truck cabin and lorry flatbed assets. In addition I’ve made some small optimisations, like giving portacabins proper LODs.

Ragdoll Smoothness

Our ragdolls have always been a bit jerky. Interpolation didn't ever work, and this week I found out why.

Here's an explanation for you Unity nerds: the ragdoll is made up of a bunch of rigidbodies, and Interpolation was getting fucked over when the rigidbodies were the children of other rigidbodies. The fix is to move all the rigidbodies to the root of the object. So now, when you die, the death view is smoother, and when you kill something, the ragdoll will move smoothly.


I've been running around the code looking for opportunities to optimize.

RPCs are functions that are called over the network. For example, when the player shoots, it calls an RPC on the server which shoots. Previously, finding and calling the command was done with reflection. This worked, and is reasonably fast, but it creates allocations. So the very fast way would be to have a function that would say "if we want to call this function, call it". That'd be a hard thing to do by hand, so I made a code generator that generates this code for us. Now the RPC calls are now as fast as they could possibly be, and totally allocation free.

We had a variable reference script on our HUD. Instead of the code saying "if player health changed, update this text", we can set that up in the editor, which uses reflection to find a variable to latch on to. This is awesome and makes things easy, but it isn't fast, and every call was allocating about 20b. So I got rid of it in all our code and coded it the fast way, saving us about 0.2ms every frame.

When you look at something in the game it shows a menu, depending on what you're looking at. These menus are defined in the code using attributes, and are looked up using reflection. This is slower than it has to be and was causing a ton of allocations. I used the RPC code generator to convert this to the same kind of flat system.

I also fixed a pretty large allocation in the player tick. This was a bug in the code generated by our proto system. It was a small but consistent allocation.

So the main client loop is allocation free now. This adds up to less stutters and memory usage, overall if you have a decent computer it's debatable whether you'll see any benefit, but it all adds up.

We still have work to do in other areas, so I'm going to continue down this path for another week to see if I can speed things up.

Item Store Changes

I've changed the item store a bit. We have categories for New Items, these are items added in the last cycle (usually within 1 week). We also have a Leaving Soon category, these are for items that will be removed in the next cycle.

The prices are now set automatically. When they first hit the store the price is the cheapest, then the price increases each cycle, until it reaches Leaving Soon. After that the item is removed from sale.

Currently this process lasts 7 cycles, or 7 weeks. This seems like a fair spot for skin authors, as after a few weeks sales reduce to a slow drip anyway. This means that some skins that were previously taken off sale have come back on sale, and some skins that were on sale are no longer on sale. This system isn't set in stone, so we'll see how it goes over the next few months.

Unity Update

We've updated to Unity 5.4.4f1 (from 5.4.2). This has fixed the command line "-window-mode exclusive" - which allows you to play in exclusive fullscreen mode. Which anecdotally improves framerate.

We know a lot of people missed this feature, so thought we'd point out that it works again now.

Rigidbody Optimisation

I took a first stab at physics optimisation by eliminating 70% of the client side rigidbodies in the world. This means that the physics system has to deal with vastly fewer collider interactions every frame, which of course reduces its performance impact. This is merely a first step and I have a bunch of other ideas to speed this up even more, but most of them are somewhat risky in nature and need some proper testing before we can pull the trigger.

Effect Optimisation

Many of our effect spawns weren’t using prefab pooling yet, which meant situations where a lot of players were moving around or where a lot of gunfire was going on would have a huge performance impact simply due to Unity’s gameobject creation process. I addressed this by making all of our effects compatible with our prefab pooling system, which greatly reduces the performance impact when spawning particle effects and decals.

World Serialization

I started working on a system to drastically reduce loading times. It’s a big chunk of work so I don’t expect it to go into testing for at least another week, but initial tests show that once it’s done we should see our loading times reduced to only a couple of seconds. I’m also hoping to use this opportunity to give modders control over the world generation in a second step, but I’ll post more info on this as things progress.

Culling Optimisation

Alistair noticed that a bunch of meshes, particularly a lot of the loot prefabs and some smaller static rocks, were visible from insane distances. I went over all the prefabs and cleaned them up, which reduces the number of vertices that need to be processed by the graphics card by around 100,000 and eliminates close to 500 draw calls on average.

Magnum Revolver Animations

I finished the viewmodel animations and sound effects for the new Magnum Revolver.

I’ve also started working on the third-person worldmodel, and should have everything ready to pass on to Helk to add to the game next week.

World Model Optimisation

As Garry mentioned last week, I'm now looking into world model budgets and making sure all assets have the correct LOD counts and setup. We're not sure on the gains at this stage, but every little helps. Having all assets fit without our new desired budgets Is also a more organised approach moving forward.

Item World Models

I have another big list of items to go through this week. We’re wanting it so that everything that you can pick up into your inventory and can dump on the ground, the model that represents it isn’t a burlap sack but what it actually is. The list is focused more on resources, like animal fat, coal, HQ metal, cloth, gun powder, CCTV camera etc - so this week I’ve made a good start on these and will be continuing throughout the rest of the week on them.

Sound Optimisation

I’ve done a bit of optimisation in the sound system this week. There’s two main places we made some good performance gains at:

First off we’re completely removing reverb zones until you’re actually in them now. We found that, similar to the particle system stuff we discovered recently, disabled reverb zones still impact performance. This has saved us around 1ms a frame (sometimes more) on proc map, so it’s fairly significant. When we first started adding reverb zones to the map there were only a few of them, but the caves added a lot more, which made this perf hit pop up on our radar.

The other spot we’ve made some gains has to do with the way we recycle sounds. Previously we had issues with the game crashing when we stopped a sound and removed the gameobject it was on at the same time, so we had a little delay built in to wait half a second between stopping a sound and recycling a sound. This doesn’t sound like it’d be a problem, but Unity continues updating AudioSources that are stopped or paused, so there was a little bit of overhead. We’re not sure if the crash we had been experiencing was fixed with a Unity update or if it’s just a non-issue because of the way we’re pooling sounds now, but it seems to have disappeared. We’re recycling sounds immediately now which isn’t as large of a perf boost as the reverb zones, but it helps a little bit.

Animal Sounds

I continued working on animal sounds this week. I’ve paused finishing up the bear until the new model/animations are done just to avoid doing work twice. All the source material for the roars is recorded, and I have the processing/effects chains set up and ready to go, so all I need to do is arrange everything to fit the new animations once those are ready.

I spent most of my non-optimisation time on the wolf sounds this week. I’ve still got a little bit more work to do on these, but here’s two of the old wolf attack sounds followed by two of the newer ones to give you a taste:

Working on the yelps when a wolf gets injured or dies is still one of the most depressing things.

143 January 12 2017
  • new

    Added purple loot box

  • new

    Added new truck variants

  • removed

    Wood armor cloth cost removed

  • removed

    Removed unused components from animals

  • removed

    Removed unused complex colliders from the local player

  • fixed

    Fixed player movement issues, especially jumping

  • fixed

    Fixed impact particle effects not playing

  • fixed

    Fixed performance hits from smoke_1 and smoke_2 warnings on explosion effects

  • fixed

    Fixed layers on the bunker room placeholder art (building exploit)

  • fixed

    Fixed -window-mode exclusive

  • fixed

    Fixed player preview not working in some cases

  • fixed

    Fixed code lock lights wrong in some cases

  • fixed

    Fixed rocks changing overall tint when moving

  • updated

    Optimized reverb zones

  • updated

    Optimized sound recycling

  • updated

    Increased Ceiling Light Brightness

  • updated

    Reduced water bucket metal cost

  • updated

    Ceiling lights no longer turned off by water

  • updated

    Increased oil barrel yield but decreased oil barrel spawn frequency

  • updated

    Plants grow faster in Planter Boxes

  • updated

    Plants have an increased yield when consistently exposed to water

  • updated

    Plants do not grow very fast in shade but much quicker in sunlight

  • updated

    Plants grow much faster under ceiling lights

  • updated

    Corpse Flies no longer fullbright at night

  • updated

    Junkpiles spawns have new variants

  • updated

    RPC optimizations

  • updated

    Clientside menu optimizations

  • updated

    Clientside HUD optimizations

  • updated

    Ragdolls move more smoothly

  • updated

    Optimized particle effect spawns using prefab pooling

  • updated

    Optimized decal spawns using prefab pooling

  • updated

    Reduced client side rigidbody count by 70%

  • updated

    Optimized all loot prefabs

  • updated

    Optimized some static rock rendering distances

  • updated

    Optimized deferred mesh decals

Mailing List

If you want to follow this project you can sign up to the mailing list.

We'll only update you about this project, we won't spam you about other stuff or sell your email address.