Problem Using Pathfinding

Get help using Construct 2

Post » Wed Jun 12, 2013 1:57 pm

Hi All,

I was trying to create a 'very' simple goal system, the sprite starts at home, goes to the dungeon, and stays there until their health got low or they got enough gold to buy something.

But I can't get the AI moving just with pathfinding.

https://www.dropbox.com/s/if8r2os8czlh7kk/Pathfinding.capx

In the example you can control a sprite to visit dungeon for gold but loose health, store if you have 100 gold and home will heal if your injured and each place acts like it should.

The AI is pathfinding (only different it gets gold from the home and health from the Dungeon), it knows where its going, but its just not going there, add bullet behavior and it will move along the pathfinding, but bullet is not ideal

I am sure I am doing something very basic/silly but I am just not seeing it, I looked at the examples and searched the forum but yeh its got me stuck.

Any help would be appreciated.

This is the demo version, using chrome..so if that does make a difference let me know, but I couldn't see any reason it should.
B
4
Posts: 3
Reputation: 281

Post » Thu Jun 13, 2013 3:42 pm

I found my problem..I was constantly finding a path so it was to busy looping over that to actually do any movement.

When you have it in response to say a mouse click, it registers the click and finds a path, then find a path triggers and it starts moving along it, but I had when health was less then 5..so it just keep finding a path while health was less then 5 and not actually moving along it.

The fix I did and please let me know if there is a better one, 2 boolean variables
'In trouble' and 'Going Home'
In Trouble would set to true if health was 5 or less.
But the pathfinding would only run if Going Home was set to false.

In the script I find a path and set Going Home to true, so it can no longer try and find a path, since going home is now true.

After its home and healed, set both In Trouble and Going Home to false, they will not re-trigger because its full health, and then do the reverse to trigger the go out and hunt.

i would post the capx but I rushed what I did so its in a bit of shambles, but if someone wants it just reply back.Kalaith2013-06-13 15:42:46
B
4
Posts: 3
Reputation: 281


Return to How do I....?

Who is online

Users browsing this forum: blackhornet and 14 guests