Posted By
|
Message
|
PotatoCannon
Registered 20/07/2008
Points 463
|
11th December, 2010 at 12:37:20 -
in my game i'm making, i have an area around the player that detect if it is any monsters around. If the monsters are in the area, the monster will start following my player. and if i hide under a tree, the area will go smaller...
Here is my question!
I want my little area thing too bend around the objects. Like if i'm hiding around a house. i dont want the monster to see me... look the picture!
http://i633.photobucket.com/albums/uu52/j0nte33/hiding2.png
i want the area to be like this:
http://i633.photobucket.com/albums/uu52/j0nte33/hiding3.png
is that possible?
n/a
|
PotatoCannon
Registered 20/07/2008
Points 463
|
11th December, 2010 at 12:45:21 -
here is an easier picture:
http://i633.photobucket.com/albums/uu52/j0nte33/hiding4.png
n/a
|
Don Luciano Heavy combat pancake
Registered 25/10/2006
Points 380
|
11th December, 2010 at 14:22:46 -
One way this could be done is to create a bunch of detectors every second or even always, im not sure would it work properly but you can try.
every 1 sec
global = 0
-
create detectors around player, one for each direction,and set their directions accordingly.
set global to 1
global<>0
detector flag 0 off
-
flag 0 on
create detector in the direction of the detector, (you can use action points and dont forget enable automatic rotations for this, maybe even launch object)
add 1 to global
if detector overlaps tree or house destroy it, preventing it from spawning another detector in the same direction.
global=10 (which would be max range)
do collision tests for enemies and destroy all detectors and set global to 0 to reset checks.
Code me a sausage!
|
Sketchy Cornwall UK
Registered 06/11/2004
Points 1971
|
11th December, 2010 at 14:54:03 -
Search for "Line of sight" - there's plenty of information on the topic.
Here's an article that should help:
http://www.create-games.com/article.asp?id=2137
If you need the area to be be highlighted like in your pictures, then that's going to be much, much more complicated. Check out Andos' shadowcaster demo to see what I mean.
One simpler idea I tried, was to use lots of triangular actives, pointing out in all directions from the player. I'd keep increasing the X scale until they hit an object, and keep changing the Y scale so that the angles of the triangle stayed the same. Even with HWA it was too slow (too many fastloops with trig functions), plus it was very imprecise.
n/a
|
|
|