sprite pathfinding around another sprite in grid.

Discussion and feedback on Construct 2

Post » Sat Feb 01, 2014 7:31 am

So I was wondering if any of you awesome forum people could help me fix a few small things bugging me that I can't for the life of me figure out.

   Here goes: So after many many attempts to create a tactics like movement system, like final fantasy tactics or fire emblem, I managed to get something good working, with a few small things that bug me.

   The hero and the enemy's take turns moving on a 32x32 grid, and can move a certain radius depending on their 'move' stat. To accomplish this I create 'move boxes' in a radius around the sprite that is moving and they can move to any one of the 'move boxes'.

The problem is the enemy can move through the hero, (not on top of the hero, thanks to destroying 'move boxes' that collide with the hero) to get to a move box on the other side of the hero. Likewise the hero can move through enemy's(but not on top of them) to get to a move box. Very frustrating.

What I want to happen is if the hero is in the way of the enemy getting to their target move box, they go around the hero. Same with the enemy in the way of the hero getting to it's target move box, that way enemy's can box in the hero if they are surrounding him.

So TLDR: I need my 'hero' sprite to find a path around a 'enemy' sprite and not go through it, while staying in a 32x32 grid.

If anybody can understand this jumbo topic please please help



I can't post the link to the .capx thanks to the great 'spam' blocking software on this website so if anybody knows a way for me to post it, I have it uploaded.




nightowl79a2014-02-05 02:36:54
B
5
S
2
Posts: 4
Reputation: 649

Post » Sat Feb 01, 2014 7:32 am

http://
www.
2shared
.com/
file/MmwR1KLm/tacticgmae
.html

haha! Got it, just combine for the link to the .capx file.nightowl79a2014-02-01 07:33:50
B
5
S
2
Posts: 4
Reputation: 649

Post » Sun Feb 02, 2014 12:35 am

I'm running into similar problems with my game. Even though my game is a bit different, the goal is the same, to have characters not just walk through each other when pathfinding.

The problem is that I can get one person to go around the other, but it always screws over the other person.

I've tried making them solid, which will cause someone to walk around them, but then they can't move at all.

I tried custom obstacles being added, but I wasn't able to make any progress with that either. Maybe I should look into it more.

I tried fooling with the path cost, but it didn't seem to do anything. Maybe I was doing it wrong though. I'm fairly new to pathfinding behaviors.

The problem may be centered around the fact that all is well until the "path obstacle" moves. Regenerating the obstacle map is supposed to be resource intensive, and I don't know if it can be done with things are moving around.

There are maybe a couple more tricks or workarounds I can play with. I'll try some more tonight.DrewMelton2014-02-02 00:36:38
B
82
S
30
G
35
Posts: 340
Reputation: 23,071

Post » Sun Feb 02, 2014 4:24 am

A suggested workaround for regenerating obstacle maps was that you move all static objects (non-moving objects) outside the layout area, then regenerating the obstacle map and placing the objects in their original positions.
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,836

Post » Sun Feb 02, 2014 5:36 am

I would think without seeing the capx that all you need is to create a barrier that these two would be forced to go around and then have that be invisible and pin it to the sprites needed to be gone around.
B
28
S
5
G
2
Posts: 77
Reputation: 3,087

Post » Wed Feb 05, 2014 2:15 am

The normal path finding behavior dose not work because the sprites won't stay in a 32x32 grid, I also tried a plugin I found called AStar path finding, but that don't work for me because it goes out of the 'movement range' tiles that I need my sprites to stay on.
B
5
S
2
Posts: 4
Reputation: 649


Return to Construct 2 General

Who is online

Users browsing this forum: bp6, TheRealDannyyy and 5 guests