User Tag List

Results 1 to 9 of 9

Thread: Tower Defence - Dynamic Pathfinding for Enemies

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Jun 2006
    Location
    Australia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Tower Defence - Dynamic Pathfinding for Enemies

    This is an example I made demonstrating Dynamic Pathfinding for Multiple Duplicates.

    I made it with a tower defence game in mind, though it can be easily applied to any game where pathfinding through obstacles is required. I noticed that people were asking how to make a 'true tower defence game' where the path that the enemies follow is dictated by the towers that the player builds.

    This example uses the Path Finding extension to do just that.

    Frame 1 contains automatic movement for all duplicates from their starting position to the destination. New walls/towers can be added at the mouse position at runtime by pressing 1.

    Frame 2 contains a barebones template for using pathfinding for multiple duplicates in your games.

    I started this example a few weeks ago just after releasing my Tower Defence Shoot Closest Enemy Example. I wanted to make it better before releasing it (optimizing the code etc.) however due to the recent interest in tower defence games I thought I would release it as soon as possible and perhaps update it later.

    I had originally intended to combine these two examples and make an open source tower defence engine. But I hope you enjoy this example for now. I may still do that if I have time.
    Attached files Attached files

  2. #2
    No Products Registered

    Join Date
    Dec 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Tower Defence - Dynamic Pathfinding for Enemies

    This is nice but i dont like the fact that enemies are destroyed if they cant find a path. That would make the game too easy. So how do i prevent the player from building the towers so that they block the path? And if i sell a tower and it makes a path shorter, enemies should be able to find the shorter one.
    If someone could help i would appreciate it Thanks!

  3. #3
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Jun 2006
    Location
    Australia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Tower Defence - Dynamic Pathfinding for Enemies

    They are destroyed simply to demonstrate that you can detect when the path is blocked. It was not intended to be like that in a tower defence game. I just put that in so that you could add your own code in there to do whatever you want when a tower is blocking the path of the enemies.

    What you could do is put down a "test" tower when you try to add a new tower. So whenever you add a tower you check using the Path Finding Extension if adding a tower there would block the path. If so, then don't allow the player to put a tower there.

    The pathfinding is dynamic so if you shorten the path, they should also automatically update their path to be shorter.

  4. #4
    No Products Registered

    Join Date
    Dec 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Tower Defence - Dynamic Pathfinding for Enemies

    Thanks for the idea of the "test" tower.
    But i made a quick test if i could sell towers:
    -upon pressing "2"
    Mouse pointer over "tower" ->destroy tower

    So i made a hole in the center and after that blocked the 3 existing holes in the map. So there still was a hole for them to go but all the enemies were destroyed..

    My head is empty and i just cant figure out what to do with this selling thing


  5. #5
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Tower Defence - Dynamic Pathfinding for Enemies

    If you delete a tower you need to tell the pathfinding object that the grid space the tower was in is available again. It still thinks its blocked.

  6. #6
    No Products Registered

    Join Date
    Dec 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Tower Defence - Dynamic Pathfinding for Enemies

    Ok i told the pathfinding object when a spot that tower was sold is available again. But its kinda buggy and sometimes 1 of the enemies just stops moving at all... Its been a while since i really used mmf2 so if someone has time, could you please show the lines required in the event editor to make it work smooth?
    I'm planning to make it something like this
    http://www.onlinegamesquad.com/index.php?1085-1

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Jun 2007
    Posts
    481
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Tower Defence - Dynamic Pathfinding for Enemies

    Application crash !

  8. #8
    No Products Registered

    Join Date
    Dec 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Tower Defence - Dynamic Pathfinding for Enemies

    ??

  9. #9
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Tower Defence - Dynamic Pathfinding for Enemies

    Why dont you use the Advanced Pathfinding Object instead?
    Its a much better extension and stores all paths within the object itself. The only thing is you need .NET 2.0 or above (i think) for it to work.

Similar Threads

  1. Issues with Programing a FPS Tower Defence.
    By DriftingFable in forum Multimedia Fusion 2 - Technical Support
    Replies: 21
    Last Post: 1st May 2010, 11:20 PM
  2. Tower Defence Help
    By Destroyer0203 in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 1st January 2010, 12:33 AM
  3. how do you make a tower defence game?
    By brad in forum Multimedia Fusion 2 - Technical Support
    Replies: 25
    Last Post: 22nd November 2009, 07:53 PM
  4. Tower defence
    By Algul in forum File Archive
    Replies: 14
    Last Post: 1st June 2009, 12:22 PM
  5. Tower defence Range
    By Zmaster in forum Multimedia Fusion 2 - Technical Support
    Replies: 13
    Last Post: 19th October 2008, 08:01 PM

Posting Permissions

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