[Tutorial Request]: Stealth Mechanics

Hello Community,

 I was thinking of some pretty cool ideas (as everyone does) and I couldn't help but ponder on the idea of a stealth game (Similar to [Tenchu z](http://en.wikipedia.org/wiki/Tenchu_Z), if you've ever heard of it). The only problem however, is that I've been searching through some documentations and other various places on the internets, however I was unable to find anything in relation to any sort of stealth mechanics. Meaning, I couldn't find anything that would help me piece together a way to have players more easily detected in the light, if they are being loud, or if they have the stench of blood on them.

I hate to do this, however I don’t suppose anyone might know how to accomplish these sorts of things in blueprint? Or is this something that C++ is more geared for?

If there are no Blueprint functions for giving you an idea of light levels, then it will definitely require some C++.

C++ then, eh? That petrifies me to be completely honest. I suppose I must go through some courses then.

I don’t believe that is what Chris is saying, he’s assuming you did some digging within blueprint.

Why not create a light class that draws a line or gets a distance to a player once they enter the attenuation radius. As they get closer, the threshold to being found increases. You can tie this threshold into standard actions, such as uncrouched walking/running, jumping, spells, etc…

C++ shouldn’t petrify you. There are loads of tutorials online, and well documented starter templates included with UE4, meaning going in to hack something to your liking has never been easier.

Alright I’ll give this a shot. I’ve been studying the blueprints system, and even though I’m a visual person the information doesn’t seem to click with me…at least not yet. I’m just worried to delve into the realm of C++ specifically for the reason of information not sticking with me.

Thanks Havoc, I’ll give that a shot and try to post my findings

Hey ,

You should be able to accomplish everything you need to using Blueprints only. Kris’ suggestion is if you want to have the functionality of knowing exactly how much light is hitting your character, that will require some C++, because it’s not a very easy thing to boil down to one number.

I would not suggest that route. Having a gameplay system tied directly to the lighting and graphics system like that is bound to cause a lot of headaches. Later on in development you realize the maps are too dark overall, so you tweak up some light levels, and now all of a sudden you have to rebalance your gameplay.

Instead, I would suggest using the Blueprint system tied to your lights. So instead of just putting plain spotlights or point lights in your map, you’ll make a Blueprint class that includes the light source but also includes a Blocking Volume in the same shape as the light. So for spotlights you can use a cone blocking volume, for point lights you can use a sphere volume. Set their Collision Preset to custom, and ignore everything except for Pawn overlap. Then you can add overlay events through Blueprint so that when a Pawn overlaps the light’s blocking volume, you calculate the distance to the light (useful for point lights), and get a value that you then add to the stealthy character.

Your stealthy character could have an array in Blueprint of “light received”. Every light that overlaps with them adds to that array. Then you would calculate the character’s “Light value” based on the number and power of the lights whose volumes they are overlapping.

You should really check out the Blueprint Office example in the Marketplace. They have security cameras that do some complicated things with Blueprint, and they do the same of having a spotlight with a capsule trigger, and when they detect a person, the light turns red and follows the player around.

Hope this helps.

The Blueprint method suggested by DanYouhon would basically let you, for lack of a better term, create Hollywood darkness. This is the kind of darkness where the audience (i.e. the player) can see everything that is going on, while the actors (i.e. npc’s) can’t see anything.

Unless you looking to emulate Thief, use that.
Oh, and by Thief, I mean Thief : The Dark Project - not the pale comparison that was released this year :stuck_out_tongue:

I really want to understand the functions and such of blueprints, and potentially C++. I get that it’s mostly common sense, and I’ve been around the documentations and such however like I said for whatever reason, information just isn’t sticking with me. It’s rather infuriating.

I’ll take a look at Thief and see what’s going on with that. Like I said I’ll go ahead and try out what has been suggested, I appreciate all of your help by the way, thanks!

Online interposed High five

I believe the “Blueprint office” demo on the marketplace has a camera using blueprint to spot the character. There is no light system but this can be a starting point. A simple (but maybe long) way would be to use volume to set a level of visibility of the player. And depending on this level, the player would be more or less easy to detect.

When standing still in a lighted room the player has a visibility of 100. When crouched in a dark room, he has a visibility of 10.

The NPC would have to check this level and if it is above their level of awareness, it would mean that the player is spotted.

I also aprove about making a tutorial on stealth mechanism.

As others have suggested, set up your level so that every light as well as wherever the sunlight might be hitting is defined by a blocking volume. Then simply set a variable whenever the player enters/exits those volumes to keep track of whether they are in the light or shade. You could even do varying levels of shadow based on how far the player is inside the volume. Then just add some additional features like requiring the player to crouch while out of the light to make use of the stealth system, etc. You could then wire up AI to ignore the player if their ‘hidden’ variable is true or false, but have other AI that could still detect you (like the dogs in Thief, for example).

You can even go one step further and have AI walking around with flashlights or lamps which also have blocking volumes matching the cast dynamic light and then the player would have to avoid moving obstacles as well.

Even though this is the simplest solution, is may be tiresome to place volume for every lights. Is it not possible to directly get the amount of light on a character? If this amount is above a certain limit the character is considered in the dark or light and other can react with this boolean. Isn’t there some native function in the motor?

In Shadows != hidden. This is totally silly, volumes give better control. If you count shadow on ground where player is standing he will be invisible if his left foot is in box. to avoid it you need to calculate at least few spots and not in environment but on players skeletal mesh, then you need to count in postprocess effects. You also cannot check color or darkness of environment because walking on black asphalt would make player hidden. And player in bright light can be hidden if he is behind obstacle. This is just too complicated to make it accurate and fast with calculations only.

Navezof’s solution with volumes is nice one, and i am afraid only one that is practical. Add to this range check to all guard pawns, then few traces from their head to player body parts, and you have well working system. You do not need more than this for developing. Only when you have dynamic light for whole scene that moves where shadows is this system fails, for everything less than that its best.

When you develop and your game is ready for alpha build you will probably know enough or have team member that can code proper automatic shadow detection. Or maybe until then Epic adds some native support for this, or somebody will do this until that point.

Splinter Cell 1 readme has entire logic of visibility calculation desribed in readme, sorry i can not find that readme on my hdd but google and torrents can help to get it :wink:

Im actually trying totally different, somewhat crazy and revolutional approach for visibility and audibility calculation in our hardcore stealth game S3 PROJECT, instead of using traditional methods with quite unrealistic and fake results, im using sort of monte-carlo method - with help of GPU physics acceleration, light and sound sources spreading invisible particles that propagate, collide, bounce of some surfaces and got “absorbed” by others. Primary (shadow\lights) visibility factor calculated by density of light particles (i call them photons, because well, idea was to make simplified model of realistic light distribution, which is not enough to draw eye-candy realistic lights, but enough to get idea of how many “photons” reflected by player model we have) that propagated from light sources and bounced of player in direction of NPC vision cone apex, to make sure that we got right particles anything that got out of vision cone does not count, and actually for performance reasons this calculation happens only when player model collided with vision cone. Almost same apply to sound particles except that instead of vision cone there are inner and outer spheres, inner-small one with size of head the one particles should reach, bigger outer one triggers propagnation of sound particles of anything that moves and collide with objects and surfaces inside this sphere.
There are other factors of visibility in our S3 project such is simulation o real vision and visual memory of npc in mulitple render targets (low res and simplifed for performance reasons) for realistic and natural motion detection of player, and detection of player blending into environmen and change of object states and placements , but they are probably too insane, complicated and experimental to recommend them for general usage, until you are totally obsessed hardcore stealth addict like me, that wants genre to evolve no matter the cost XD

All methods suggested by people above was good back in an old days, but they are very fake, making game very simplified and frustrating in core of stealth mechanics, people still living 90th in their minds, but we ca do better than this in 2014, we must do and GPU accelerated computing can help us a lot with more realistic, interesting and chellenging AI and gameplay.

I feel like it could be interesting to have a different difficulty setting which uses the older methods of visibility and audio, and then make a difficulty that adds the new style of stealth. I’m still working on this, however I’ve been delayed as I’m trying to learn more about the engine, blueprinting and the like. Let me know how your progress is going, v00d00m. Do you have a thread about S3? If so I’ll head over there and take a look!

I’m a hardcore stealth fan, by nature. I started with platformers, such as Crash Bandicoot, and the first Tenchu was a stealth platformer. I really want to make a homage to Tenchu, I guess more than anything. It was the second video game I had ever played in my life - and it defined me as a player.

Since that moment i found OpenCV-CL library and there was some successful experiments of simulation of realistic kind of vision for NPC i was talking about, with motion tracking, recognision of player model in shadow and light and changes in scene, in real time, thanks to this computer vision gpu accelerated library. But this prototyping was not yet integrated to UE4 code. If playtest results of using only it would be successful, i think it could be used alone without aid of other visibility calculation methods. In theory it sounds like most realistic one, in simple test it surely looks like, but in real gameplay situation i dont know yet how well it will work, especially with many npcs in scene, so other mothods are still involved and in the end i think i would combine them and use set of conditions for various situations.
Here, take a look at this library: