Vision Cones — Revamped Visibility
I refactored the NPC vision cones to draw better visibility. This is something had been stabbing at on and off over the last couple of months, and I finally have them running well.
Old vision cones:
The old vision cones were an overlay and would overlay past any sight obstacles. I had always found this somewhat annoying, because you could be behind a wall and still see the cone over the area. It could make it difficult to discern what the enemy could actually see.
New vision cones:
With the new cones, I ditched the overlay and implemented true visibility. Now, the vision cones are blocked by walls and anything that the enemy cannot see over. It gives a much better indication of how hidden you are. This was a big ticket item on my mechanics list, and having now checked it off, I don’t think there are anymore major mechanics left for the engine.
The new visibility could use a little more optimization. I get made fun of a lot by my tester for being strict on performance, but it is important to me. I am still nailing down what the system requirements will be, so I have some flexibility. The game is not heavily threaded, so a single core should handle things fine. An old 2.0ghz dual core mobile w/ Intel GMA on board pulls a consistent 40 - 60 fps, so the game isn’t very taxing.
One change I’ve made recently is tying Clea being burned to her stamina gauge.
A few actions/reactions in the game world are tied to Clea’s stamina meter. The main action is running, which continuously drains stamina until it is empty, or you stop running. Stamina then goes into a short cool down mode before beginning to restore slowly. I felt that stamina was underused, so I began making some other things dependent on it.
The first thing I tied to stamina was being mauled by the Attack Dog. Originally, when a dog mauled you, you had around 2 seconds to press ‘use’ and knock him off. Now, when a dog mauls you, your remaining stamina dictates how long you have to knock him off before dying. A full gauge will give you a little over 2 seconds to react. If you are mauled post-sprint, you are essentially done for.
Now, being burned by fire is tied to the Clea’s stamina and is no longer instant death. It drains stamina quicker than being mauled, but should give the player a moment to run out of fire if accidentally walked into. This change mostly benefits those with quicker reflexes.
In the above GIF, you can get an idea of how little time you can stay in fire. Also, you can see Clea’s new “burning death” animation.
Here are the changes since the last progress report.
- Skipped unneeded state checks for some enemies. Fixed them being alerted when they shouldn’t be.
- Cached some math results and collision info to speed things up.
- Burn death animation for Clea.
- Darkened some tile layers to add some shading depth.
- Attack Dog bark and gunshots (duh) now scare Bystanders.
- Smoothed out looking when hitting distance bounds. No longer stops and sticks, but glides along boundaries.
- Remade projectile impact animations.
- Optimized vision checking for occluded entities.
- Attack dog’s bark alerts his position, not the player’s. Makes enemies look dog’s directory.
- Fixed — Killing an unalerted Sentinel ends alert event when another Sentinel is alerted.
- Math optimizations.
- Sound work: For level transitions.
- Added projectile travel sounds.
- Added new grenade explosion sound.
- Enemy timer values (being alert, delays, etc) are more randomized to add some reaction time realism.