I See You
*UPDATE 11/30/12-- Fixed erroneous sensing-- fixed baddie not sensing after first alarm*
A little engine I whipped up that gives enemies the ability to detect a player by seeing them- he can only see you if he has a direct line of sight, is facing you, and there isn't a wall in the way!
Step into the view of the enemy and watch him spot you and charge at you! Move out of sight and he will become confused and resume walking.
The real useful part to this engine is that enemies cannot see you when you are behind walls. This often causes bugs in games, but this engine offers the solution!
Also featured in this engine is one that allows free-form costumes of varying shape to cycle around without affecting sensing. I decided to make some doodles the sprites out of interest, sorry that they look blurry and hard to see. Keep in mind that's not the focus of the engine.
Click the button in the top right to change the map. The second one shows the uses this engine can be put to, luring enemies off of cliffs.
Download the project to see helpful comments on what each part of each script does.
--Enemy must be facing you.
--There must be no obstructions between you.
--Enemy must be within 200 pixels.
--Sensor does not work in Flash occasionally. (The reason for this is that the sensing sprite is a single pixel large, and rotating this pixel can occasionally make it 0 pixels wide, and sense nothing.
--Once the enemy sees you, he sometimes cannot lose sight of you.
--"Losing sight" animation looks very similar to the "I See You" animation, causing confusion.
--Sprites have inconsistent brightness.
--After the enemy has seen you once, he may not see you again after losing sight of you.