PathFinder Enemy Inteligence

Get help using Construct 2

Post » Mon Apr 29, 2013 6:45 pm

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
Base PathFinder Solution

@Ashley
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Tue Apr 30, 2013 3:56 pm

Anyone?
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Mon May 06, 2013 7:49 pm

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
B
8
Posts: 32
Reputation: 1,039

Post » Tue May 07, 2013 2:40 am

Thank You so much! I had not remembered the Family Solution!
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Tue May 07, 2013 3:00 am

@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?
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Wed May 08, 2013 3:40 pm

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
B
8
Posts: 32
Reputation: 1,039

Post » Wed May 08, 2013 3:42 pm

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)
B
8
Posts: 32
Reputation: 1,039

Post » Wed May 08, 2013 3:57 pm

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 bestthatjoshguy2013-05-08 16:01:50
B
8
Posts: 32
Reputation: 1,039

Post » Thu May 09, 2013 7:42 pm

@thatjoshguy
Look here one Solution that I've implemented!

https://docs.google.com/file/d/0B4gkRQY2H_o6ZlRydUROTGxod00/edit?usp=sharing

Thank you for your assistance, it helped me get the north to solve the problem.
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Fri May 10, 2013 5:49 pm

no problem, glad I could help. I'm jsut starting out, and the forums have been a wealth of information!
B
8
Posts: 32
Reputation: 1,039

Next

Return to How do I....?

Who is online

Users browsing this forum: flemmig, Matthew de, semaso, Skebab, Virpoja and 20 guests