object never reaching pathfinding target spot

0 favourites
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • hi im 16 and im making a 2d platforming game for class. I was trying to make an NPC move on an island in a straight line from one point to another and back again only moving on the x axis. I had what should have been the right programming setup with no obstacles in the way but whenever I ran it he would only go one way and when I looked at the debug preview it seemed like he never made it to the target point. the target point was right,the calculations had ran and he was moving and even got to the correct coordinate but the program said he never reached it. i also ran several tests to see if my hypothesis was correct. it was. as far as I can tell he(the object) is never reaching his target location. and the weird thing is at one point his coding did work.I never changed his code except where he was meant to go which was still only on the x axis and still going in a straight line the same distance. I have no idea why its not working and I have been working on this problem for over a week.please help.

    Tagged:

  • oh yeah I also forgot to mention the problem only happens when I try to send him back the other way afterwards. I just went and tested it....

  • It would be easiest to help you in this case if you post your code. This stops us from guessing possible reasons that aren't necessarily related.

    If you don't want to share all of your code, giving us at least the pathfinding code can get us started. ^^

  • umm idk if there was a way to insert the code in a diffrent way but here

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"is-enabled","objectClass":"Flaugus","behaviorType":"Pathfinding"},{"id":"pick-by-unique-id","objectClass":"Flaugus","parameters":{"unique-id":"74"}}],"actions":[{"id":"find-path","objectClass":"Flaugus","behaviorType":"Pathfinding","parameters":{"x":"4050","y":"4740"}}],"children":[{"eventType":"block","conditions":[{"id":"on-path-found","objectClass":"Flaugus","behaviorType":"Pathfinding"}],"actions":[{"id":"move-along-pathfinding-path","objectClass":"Flaugus","behaviorType":"MoveTo","parameters":{"mode":"direct"}},{"id":"move-along-path","objectClass":"Flaugus","behaviorType":"Pathfinding"}]},{"eventType":"block","conditions":[{"id":"on-arrived","objectClass":"Flaugus","behaviorType":"Pathfinding"}],"actions":[{"id":"stop","objectClass":"Flaugus","behaviorType":"Pathfinding"}]},{"eventType":"block","conditions":[{"id":"compare-x","objectClass":"Flaugus","parameters":{"comparison":0,"x-co-ordinate":"4050"}}],"actions":[{"id":"move-to-position","objectClass":"Flaugus","behaviorType":"MoveTo","parameters":{"x":"3482","y":"4740","mode":"direct"}},{"id":"move-along-path","objectClass":"Flaugus","behaviorType":"Pathfinding"}]}]}]}

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You want to do a screenshot then crop down the image size to show only what you want, or if you are on windows you can use the snipping tool (Shift + windows key + s) which lets you screen shot a selected rectangle. Save the image and upload it in the reply window.

    Or save the C3 file and load in here - I see that a lot but I have never done it. So honestly I'm not sure what's involved.

  • All your events are attached to your initial event.

    You want to break it down into separate events.

    Also if you only have one instance of Flaugus you don't need to grab them by ID.

    Just looking to move Flaugus between 2 points I would do something like this:

    (The spacing is messed up in the forums so I did a screen shot)

  • wow thank you i dont fully understand just reading it but I think if I mess around I can figure it out.. how do you get the "and" bit? cause its not like scratch where there is an and block and its not quite like JS either...

  • And is automatically applied to Conditions inside the same block. I was just trying to explain it in words that they need to be grouped together.

    (Example of And)In your code from the ScreenShot

    Flaugus Pathfinding is enabled

    Flaugus Pick instance with UID 74

  • thank you! that makes a lot of sense now! i still have to try it out but im really hopeful! also I do have more than one flaugus so that is necessary

  • then I add the if pathfinding path found move along pathfinding path right?

  • Ya that's in mine at the end. AnyTime any Flaugus finds a Pathfinding they move to it

  • Here - Ignore everything so far and work off of this. It is a working model that calls 1 instance of my flaugus's and moves them with pathfinding back and fourth

  • I just tried it and umm he still wont move i will put in a picture of my code but idk whats wrong. I stillam really hopeful and this has been really helpful

  • Code looks right to me.

    Verify that he is actually UID 74?

    Verify that whatever he is starting on is not a Solid or stopping him from moving?

    Verify pathfinding is actually enabled?

    Otherwise it's possible other code is stopping it from working.

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