A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Artificial Intelligence

  1. #1
    j00 r teh pwnz0r3d DarkMagicHacker's Avatar
    Join Date
    Feb 2001
    Location
    Your mom's room.
    Posts
    622
    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.

  2. #2
    Junior Member
    Join Date
    Apr 2001
    Posts
    8
    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.

  3. #3
    Gross Pecululatarian Ed Mack's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    2,954
    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.

  4. #4
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    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

  5. #5
    ....he's amazing!!! lesli_felix's Avatar
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    1,506
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center