How do I fix this pathfinding issue

0 favourites
  • 9 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Ok so Ive been working on an example to make a battle arena type that would make a border of the battle when you collide with an enemy and then start the battle.

    And here I was thinking oh hey I can totally use this giant arena sprite and add in image point to control enemy Ai movement by using Pathfinding.

    and so I name each point Action with a number of 1 - 9 and its laid out in a grid so that the enemy would choose a number and then I would path find to that sprite image point using

    Sprite.imagepointx("action"&(enemy.B_action)) Same goes for Y.

    Ok cool it moves .....wtf its isnt even going to the right spot its running into the border its get stuck refuse to move it pass up the spot its suppose to be at.... Ive tried on path finding arrived stop .....It just get stuck refuse to move after. and sometime if i do get out of the battle arena that same sprite seem to follow a pathfinding ...even if the object is destroyed.

    Here my question is there a way to see the pathfinding in action in a line so i can See what the bloody hell is happening or would you guys like to take a look at it ?

    https://www.dropbox.com/s/gyfsaablosqiy ... .capx?dl=1 This will auto download.

    I found a really strange behavior so i move the variable from the sprite to a local variable and then I added in if it zero then choose 1-9...this shit just infinite choose itself how is that possible what ever I place a once trigger that stops it. ok fine next nothing will make it find a path so i did a little test of just one at a time. It still refuse to move. Im at lost in this pathfinding shit. also i found something strange is that if you dont have the variable with a once trigger then it will infinite find a path without letting it move. So i re did the code to just that one variable and no choose....now it wont move at all. I cant tell if it unable to find a path or the waypoint of the path does not exist what the bloody hell is going on. This shit is freaky.

  • The first thing is see is that the pathfinding object is a solid it self, while having the pathfinder behaviour set to avoid solids. It can not not reach out itself. Either dont make the pathfinding object a solid, or dont make solids an obstacle.

    Also. I am not sure that the collision polygones as set in the battlefield sprite work as expected when they have to repesend a solid to a pathfinding. Would it not be esayer to just use 4 solid solids ?

    Also. I have no idea where 833,456 is supposed to be, but it do not think it is inside the battle area.

    Maybe later i look deeper in it.

  • well I used the text to find that one spot on the image point 2 to see if it was the solid but I did manage make it move so what i might do is use something like on collide to record the x,y of each image point in a variable and then use that for a pathfinding coor.

    But i did encounter a new issue is that even if i did make to move to that destination it loop on itself trying to get there and just wobble never fully stopping ? do you have any fix for that ? cause id like to use on path arrived choose a new number to go to a random image point coor.

    What if I could do a math of where the battlefield sprite land to calculate the min X max X of the size and have a random value choose between based on where the battle field sprite lands.

    And add in on path failed to find to repick a number?

    and Ive alway thought that solid only applied to collision polygon that is set up not on the actual sprite itself ? or does contruct 2 think differently ?

  • For the 9 points, just set 9(n) imagepoints , and use the expressions Sprite.ImagePointX(n) & Sprite.ImagePointY(n) as the positions to find a path to. Pick n in a choose(...,n)

    https://www.scirra.com/manual/63/image-points

    Set the obstacles on 'custom' in the pathfinding behaviour. And add obstacles, if you need to, in actions. And do use the 'create obstacle map' at least once somewhere, if you have obstacles.

    The object will stop moving when reaching end of path, if it does not, you probaly let it find a path each tick. Or youre pathfinding has a problem.

    If i may say some things that i personal dislike in your project. They are just personal taste. Just gentle tips:

    Plz, name you sprites. Its difficult to look into a capX where everything is named 'sprite(n)'.

    You can as well after the "direction = 1" condition move the sprite. Dont need the second 'action in between agent'.

    When you enter the battle arena, all those blue solids still count as obstacles when finding a path. Needs more time to calculate, can lead to unecpected behaviour. Since now you have solids set as obstacles in the path behaviour.

    All the blue obstacles are so many collission calculations. You can speed things up by 600% when you bring them in a tilemap.

    Not that my opion counts in anyway or any other way on this forum.

    Plz yell if you still have problems.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • yeah sorry this was just a test theory and i found a better result is to use 4 four variable min x max x and min Y and max Y based on two image point. But i am encounter a really weird problem so yeah it bounces in the battlefield sprite but where my parameter for the pathfinding is going out of its boundary of min max of which variable i told it to use from ? and often times it just get stuck. And when i went to use my text box to try to find the pathfinding coor current moving to ? its keep moving never stopping ? I even remove all obstacle and turn off all solid yet it still pathfinding outside of the parameter I have set it to ? Am i missing a certain expression ?

    Oh and I rounded off the sprite polygon to see if it was getting squared stuck lol

    can you check it out ? Im trying to learn the behavior of the pathfinding but you mention tilemap I am curious do you have an example i could look at.

    You can redownload it it should be updated.

  • Is this what you want ?

    Your local variable movement got reset when its topevent runs in its next tick. Always beeing zero, every tick. So, it kept finding paths, not ever coming to move on it.

    Local variables are heaven, but you know that they reset (if you dont make them static) every time theire top event runs.

    I added obstacles in event 12. I recalculated them localy for the battlefield. INCLUDING the battlefield.

    I made the pathfinding logic in events 19 to 21.

    I made the cellsize 30 and border 1. See manual why.

    Hope you get the hang on the pathfinding thing.

  • Holy cow I figure it out ....trigger once while true during event battle condition did the trick and the Int declare on the path finding. now its so smooth...WTF lol

    And it stop at the given spot....Here the upload for the fix if anyone been following me.

    https://www.dropbox.com/s/gyfsaablosqiy ... .capx?dl=1

    this works is such a wonderful thing cause I can continue with it. Thank you for your help 99instances2go you gave me the idea about the local variable and event...so i just randomly started placing the find path until it was the right one. and then trigger once was the deal. If anyone is having a path finder issue try Triggeronce that might be what causing this mayhem

  • Geez i forgot to include the link. You solved you probs, buet here is it anyways:

    https://

    drive.google.com/open?id=0B1SSuCVV8v74aVhQUDBSdU9MVEE

  • ok So i am a little confused now it is the same game same code problem with a new one that doesn't make sense. So I have the enemy AI do a series of choosing action so far i can get it to move and use a range bullet then reset moving and then re-choose of the three variable (1,2,3) the number one is just moving around. The number two is just for range bullet to fire at the player now the third one is for the enemy to move in and use an melee attack animation.

    the variable 3 (melee) is currently being weird on me I have it set up to where when path find has arrived create object the melee animation and then when it end it reset the action to back to the moving state. .

    Now you would think that putting a variable (3) here would just do just fine....problem is that once the variable 3 is chosen it does the melee attack first and then move to the player and reset itself because im using wait by signal and that is on the end of melee animation. I suppose its reading that it has arrived at the old path finder but I thought that by having the pathfinding to move start first then arrived it should have worked

    But I know that i tried overlapping sprite did not solve it it just made a new error that it cant reset itself if not overlapping and still does the same crap as before.

    My question is that does pathfinder arrived event is counting the previous pathfinder node or is this just a dirty bug that question the existence of the event ?

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