One thing I want to emulate from Half-Life and Sven Coop is the scientists. Asking them to follow you, having them open a door for you, accidentally leading them to a gibby death, all that stuff. There's a lot of fun to be had with these gormlessm keen to help npcs.
The main thing I wanted to this week was be able to get them to follow you, and to tell them to stop following. I gave them hats to differentiate them from the players slightly (we don't have any clothes for the citizen yet).
But I also made it so they could be killed. This led to a bit of a refactor, because I wanted these and the player to share a common base. I'd resisted using a BaseEntity type system up until now, opting instead to try to make everything component based. But it really feels like the most efficient way to do stuff.
Something that might be interesting here, is that the ragdolls are created with the EventMap system I talked about last week. Because of how the skeleton system works, it only really needs a matching ragdoll prefab and it can create the ragdoll no fuss. This means that each entity doesn't have to define a ragdoll prefab, because it's just a generic event.
Here's an example of it dropping a ragdoll every time we trigger "follow.start".
Eventually I'd like them to become scared of the player, run away, avoid monsters, be able to carry things for the player, wander around, do idle chatter. But for now this is enough.
Bonus explosion video:
I also wanted to look into enemy NPCs, so I started with an easy one. One that just looks for a player that is pretty close and chases him. There's no attack, it just kills the player if it touches.
It's simple stuff, but I did do a bit of refactoring so that instead of targetting the player specifically, they chase any entity that fits in a specific category.
So they'll attack NPCs as well as players.
They're as basic as it comes right now. They get bored of chasing and give up after a while, but there's no line of sight tests. I just wanted something I could throw in a few levels to test other things I wanted to experiment with like players having health, and getting wounded.
The EventMap has come in useful with this NPC too, making it so that when I'm coding I can add a RunTrigger( "something" ) without having to worry about implementing it until later. I made it so that when the chasing state changes, it'll fire an event, which I hooked up so it makes a noise.
Remember TimeSince? Well here's an alternate version called TimeUntil.
And here's an example of using it to burp every 5 seconds
All my refractoring over the past couple of weeks has led to a lot of stuff either not working, or being partially broken.
One big thing was that it had prevented our abilities to run two instances of the game to test multiplayer stuff locally. This had a cascading effect of creating a lot of multiplayer issues because I'd fell out of the habit of testing everything in multiplayer too.
I fixed that this week, and have been working my way through all the many multiplayer issues that I've caused - including a bunch of really long standing ones going back to the time it was a golf game. It feels like it's nearly back to the stability that it was at a month ago, so I'm hoping to be able to do a playtest next week.
Continuing what I did last week, I made a proof of concept.
In this example once you plug two keys in, the green lights light up, the doors open (using a standard Unity animationclip), and interaction with the keys is locked until the animation is done. This means that the open and close can have different animation clips - because they'll always start from the same point.
I had an issue for a couple of weeks that meant that other team members couldn't open the project. It turned out it was using a package that Unity had deleted, but it still worked for me (and the build server) because we had it cached locally. I found this out because I bought a new PC for home and it was an issue there.
Changing the package to a version that exists fixed it :D
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.