Rts pathfinding

For questions about using Classic.

Post » Mon Aug 31, 2009 11:54 pm

I have a fairly large map that Im using the rts movement on. The problem is that I have a collision event that tells some objects to move to another object way on the other side. When that happens there is a huge dip in performance as the objects try to calculate the path.
So I was wondering if there was any way I can get some improvement on this.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Tue Sep 01, 2009 4:11 am

My only solution thus far has been to use a waypoint instead of move to object.
This gives a few new problems tho...
You have to dummy down the obstacles, as the pathfinding isn't nearly as good.
Then it seems that waypoint means the same thing as move to position, so my events that use on arrived at waypoint are messed up with events that use move to position.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Tue Sep 01, 2009 5:14 pm

What exactly are the events? The actions to move objects with the RTS behavior runs a potentially CPU intensive search. They are only designed to be called in triggers or one-off events - if you are calling them every tick unecessarily, you will waste CPU for no extra pathfinding benefit.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Tue Sep 01, 2009 6:33 pm

Initially I was using
family.sprite on collision with thisbasesprite
>family.sprite2 move to thatbasesprite

Now I realize that with a family there is a chance of multiple triggers so I tried it with only one object hitting the base... same result.
Im pretty sure the slow down is due to the fact that its sending multiple objects at once, and that the distance is pretty far away, layout's 3000x 3000.

The move to waypoint has no slowdown what so ever, even with multiple hits, but the fact that its treating move to position the same as a waypoint is really what messes that up.
What would be nice is a difference between the two, with an additional call like on arrived at position.
BTW I haven't tried on arrived at target, but I assume that's the same as position.
Any way I just need waypoint's to be handled separately from a position.

Also I'm still getting some hinkey results when using families that contain objects belonging to other families.

Something like family tank has tanks, family cannon has cannons, and family artillery has both.
If I tell family artillery to move somewhere, it works fine, but if I do something like get an object count it only gets one side of the family.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests