PathFinder Enemy Inteligence

0 favourites
  • 10 posts
From the Asset Store
A short demo of template sold on store, with formations on end of way for no overlaps.
  • Hi Developers!

    I'm having trouble since PathFinder inserted in a Enemy Object doesn't recognizes another Enemy to avoid them to colide with themselves.

    I know that Solid + PathFinder doesn't work and Remapping the cells are a gruesome how to apply in the solution.

    Knowing these problems, I've searched in the foruns a solution and some of you said a solution like this:

    • When an Enemy colide with another Enemy, checks who is in a greater distance and set this one to Stop or Slow down the Speed.

    Okay, in theory this is the best known solution, but I dont know how to implement it. I've tried some things but doesn't work.

    Can some one Help me Solves this?

    Solving this I'm sure it will help many of us.

    Here is a Base Capx to advance you service <img src="smileys/smiley4.gif" border="0" align="middle">

    Base PathFinder Solution

    Ashley

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Anyone? <img src="smileys/smiley19.gif" border="0" align="middle" />

  • Here's what I do: I have my enemies in a family, then I create an event for each enemy type. For example, if one enemy type is "Zombie", and the family is called "Enemies":

    Event: "Zombie"|is overlapping "Enemies"

    Action: Move "-1" pixels at angle "angle(zombie.X, zombie.Y, enemies.X, enemies.Y)"

    there may be an easier way to do this as far as referencing the family member within the family, but this works rather well. It just takes the angle between one sprite and the other, and moves on of the back pixel until they no longer overlap. This creates a smooth effect when many sprites are trying to hold the same position

  • Thank You so much! I had not remembered the Family Solution! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • thatjoshguy

    I've tried here your solution and I found one trouble.

    When an enemy overlaps with another enemy of the same type, both slows down(in my solution) because they kind fight of who overlapped with whom. Both believe that himself was the first to Overlaps with the other.

    So what to do with the same Kind?

  • In my code I reference the instance against the family. ZOMBIE is in family ENEMIES, so when I write the code to move them off of each other I move the ZOMBIE -1 pixel, not the ENEMY.

    Don't have time for an example capx right now, but here's a screencap of what it looks like in my code, if that helps:

    http://thatjoshguy.com/example.JPG

  • the downside of this approach is you would need to do this with each enemy type in the family.

    If there's a way to choose the object in C2 within the family, I don't know it. It would be awesome to do something like angle(enemy(1).x,enemy(1).y, enemy(2).x, enemy(2).y)

  • holy heck, turns out you CAN do that...

    super simple code!

    Event: "Enemies"|is overlapping "Enemies"

    Enemies Action: Move "-1" pixels at angle "angle(Enemies(0).X, Enemies(0).Y, Enemies(1).X, Enemies(1).Y)"

    Edit: no, don't do that... it seems to make things worse. I really don't know, the first way I did it seemed to work the best

  • thatjoshguy

    Look here one Solution that I've implemented!

    docs.google.com/file/d/0B4gkRQY2H_o6ZlRydUROTGxod00/edit

    Thank you for your assistance, it helped me get the north to solve the problem. <img src="smileys/smiley2.gif" border="0" align="middle" />

  • no problem, glad I could help. I'm jsut starting out, and the forums have been a wealth of information!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)