-
For some time now, I have been working on a little project. It is a platformer but it is more like a 2d version of Devil May Cry (PS2). Problem is, I don't know how to make it so the enemies cant see through walls. I want their field of vision stopped when it hits a wall. I am intermediate at flash, and I have no clue on how to fix this problem. If anyone could help, I would gladly put you in the credits.
-
i'm not familiar with the game you're talking about, so this may not help.
i assume you have collision detection that keeps the players and enemies from "walking" through walls. can't you apply a similar code/approach to the enemy's vision controls to make it stop at walls?
don't ask me for code, i've just got ideas.
-
For there view, have an invisible line going straight ahead. If it hits a wall, then it can't see the player, if it hits the player, it can. If it hits both, it takes the players coord and the hit wall's coord and compares them (My not be the best way with your engine).
If your tilebased, then its a lot more scripting I'm afraid.
-
can you post a screenshot of your game or basic outline of one level.
to answer your question you may want to move couple of times ahead and look for collision. If you use tiles you can retrieve the tile number and tile characteristics like walkable or non-walkable something in this sence..or you can put nodes and set predifined paths from node to node something like a grid..then look were the hero, is closer to wich node and get the shortest path to there..
ms
-
I haven't tried this myself, but it might be worth a shot..
Place a long, thin rectangular movieclip starting at one character, and finishing with the other. (you might have to dynamically rotate and scale it to fit, it will also need to be invisible)
Then try and detect a collision between it and any wall movieclips on the screen.
If it collides, you know there's a wall in between the two characters.
Actually, this is pretty much the same as ed-mack's idea, only with the line joining the two characters.
Ok, Here's another idea..
Give each room/chamber/cave whatever a different number. Assign a variable to each character which holds the number of the room they're in. To check if two characters can see each other, just see if the numbers match. This would only work well on simple maps, with clearly defined rooms.
Hope this all helps.