[SOLVED] Pathfinding optimization problem

0 favourites
  • 4 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • I'm trying to make a waypoint movement system where you double click to set the destination or append the current path. I found that the pathfinding behavior generates too many nodes for my purposes - I only want the bare minimum number of points but it sets extra ones around corners.

    So I fixed this with a hacky optimization where each waypoint has a line-of-sight behavior, & if it can see 2 nodes ahead then the following node is destroyed.

    This works & gives me a simplified set of waypoints. But, after 30-40 waypoints are made, there's some serious performance issues - cpu=100%, fps drops to around 40.

    I've attached a capx, maybe someone could take a look & see where I'm going wrong.

    Also if anyone has a better idea for generating a simplified set of waypoints then I'd love to know how.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't know if this helps, but If i disable your last event, the "for each node" one it pretty much solves the framerate problem.

    maybe try finding a way to only generate that text for each new node, instead of every node every time?

    or maybe the node could have animation frames each with the next number, and you could just up the frame each node?

    from the "Performance Tips" section of the manual:

    Change the size or text of a Text object every tick - even just for an animation or transition - will likely produce poor performance, especially on mobile devices. The problem is even worse if the text object is large. Text rendering is very fast as long as the object is not changing, but upon changing the object must do a relatively expensive redraw of the text and replacement of the cached texture. Try to use small Text objects that do not change regularly. If you must change text regularly, consider using a Sprite Font instead, which is fast even when it changes every tick.

  • That was it, thank you The text was just for debugging, & I thought destroying then creating it every 0.1s for <100 objects wouldn't make a dent in performance. I'll be more efficient with my debug text in future.

    So it's good to know that the pathfinding optimization works perfectly. I'll post an example file once I get a more complete system & hopefully help someone else out.

  • mattb this is pretty cool. Is the primary use for these to have other characters follow the player? What other potential uses do you see? Great work!

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