[SOLVED] Pathfinding optimization problem

Get help using Construct 2

Post » Tue Jul 29, 2014 12:43 pm

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!
You do not have the required permissions to view the files attached to this post.
Last edited by mattb on Wed Jul 30, 2014 10:42 am, edited 1 time in total.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Wed Jul 30, 2014 3:42 am

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.
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Wed Jul 30, 2014 10:40 am

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.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Fri Feb 12, 2016 5:31 am

@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!
Check out my games on Google Play:
BEAST ATTACK (1,000,000+ downloads!)
ZOMBIE BASH (Android) (Launched Feb 17)
ZOMBIE BASH (iOS) (Launched March 17)
B
54
S
18
G
2
Posts: 436
Reputation: 5,582


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, tarek2 and 14 guests