I'm trying to implement a 'Town Guard' feature seen in Oblivion and other classic RPG's: when the player commits a crime (shoplifting, hitting a harmless commuter etc.), a couple of guards soon show up to arrest him. But they don't just appear from thin air, they tail the player starting off from their barracks, so the player has a chance to evade them.

What's the best way to implement this?.. Thanks.
  • probably do something with some checks to see if a crime has been committed so say you steal something set a bool true to "crimeCommitted" (or what ever you name your bool an minus the "").. off the check to see if the bool is true you would spawn the guards at there barracks an have them go after the player if caught get put in jail or what ever
    new website can be found here http://www.fore-loregames.com

    Follow the game Development on Twitter https://twitter.com/Fore_Lore_Games

    or check out the face book page here https://www.facebook.com/ForeLoreGames
  • And you could even make the crimeCommitted check add something like a severity amount to another variable, like Bounty, which could govern how many guards come after you based on what you did. Tiny bounty, 1 dude is spawned. Ginormous bounty, send in the battalion.

    I'd also use a NavMesh set up so your guards can path correctly to your player, and set up some kind of escape criteria for your player - either based on time evading your guards or on distance from guards so they don't endlessly come after you.
    My little chunk of the internet: http://artemic.com
  • Thanks, both of you, very good suggestions.
    Will do it this way, but perhaps GiL would also like to chip in. :)

    (Instead of ''ubiquitous Town Guard'', the title should probably read ''global Town guard''.)
  • Sounds like you've already got some good advice.

    Another way could be making use of factions. E.g. having the guards already in town and crimes lowering the sympathy until they become your enemies. Or change the faction of the guards to an enemy faction after a crime.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.