Game Development Community

Hiding in the Shadows

by Alan H · in Torque Game Engine · 01/12/2006 (10:11 am) · 6 replies

I'm trying to figure out a stealth system that would work in TGE/TSE but I'm not sure of the right approach. I know what to do about the quite sneaking vs clumping of shoes but the "hiding in the shadows" a la' the game "Thief" that has me scratching my head. I know you could do line of sight for hiding behind things.

Would you just use occluders that are on the "edge" of the shadow? So when you were sitting in the shadow they wouldn't see you? Or would you just use a trigger event in the shadowed area that overides the line of sight in the AI when the player is sitting on it?

#1
01/12/2006 (10:20 am)
Check the colour of the lightmap you're currently standing on, perhaps?
#2
01/12/2006 (10:21 am)
I seem to remember NOLF2 did this... not entirely sure how it was done, but it appeared to be more zone based than any LOS with the lights..

I think the simplest thing would be like you said, create a trigger in the place where the shadow is. The closer to the center of the trigger, the more hidden you are.

How accurate do you need it to be?

You could always do ray casts to the sun position from each corner of the player bounding box. Might be expensive though, I dunno. I don't know how quick ray casts are. If any rays meet geometry, then that ray could be said to be in shadow. You'd factor in the ambient light of course and this technique wouldn't work for interiors. Maybe triggers could be used for that.

Maybe if you only do the ray casts when you've stopped and then only once or infrequently when moving, you might be OK. You'd store a PercentHidden value which the AI units could check.
#3
01/12/2006 (10:26 am)
Do what Stefan said.
#4
01/12/2006 (10:29 am)
Yep. Sounds much easier :)
#5
01/12/2006 (1:16 pm)
Thanks guys. As for accuracy I'm not sure yet as thought evading capture is one of the points of the game as well as sneaking into locations.
#6
01/15/2006 (10:05 am)
You could also cast rays from each lightsource, factor in the attenuation and brightness of the lights, and add up the amount of light on the player. You can save that and use it as a GUI element too. That would also handle dynamic sources well. If you need, you can cast multiple rays per player to see if you are just hitting the hand and not the center of the body.

Forgot to add:

you also need to factor in distance, etc, though that can be done through "sound"

for instance, when a guard walks up and nearly bumps into you, he should probably notice ;)