RTS problems

For questions about using Classic.

Post » Sun Jun 07, 2009 2:35 am

I've just returned to making my game after a long period away from construct, so I've forgotten a few things.

The problems I have at the moment are with the RTS object. I want pathfinding for the enemies in my game, but they keep getting stuck on walls and such. It also lags like crazy when I have any number of them more than 5.

Here's my cap file: [url:g55bbuf5]http://www.filepak.com/upload/1_zombiecity.cap[/url:g55bbuf5]
B
3
S
1
G
3
Posts: 105
Reputation: 1,312

Post » Sun Jun 07, 2009 3:08 am

I'm sorry but the RTS pathfinding isn't pixel perfect. If you want more precision, make the path finding grid smaller (best results are with 10x10, but it's more cpu intensive).
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Sun Jun 07, 2009 4:03 am

Ah I see. Yes it was on 10x10, that must be why it was lagging so much. I probably don't need the grid to be that small, the smallest passages are 64 wide.

edit: Ok I changed the grid to 40x40 and it seems to have fixed the getting stuck problem. It's fixed the lag problem too, however when I go around the corner I sometimes get alot of lag. Is there no way at all to solve this?
B
3
S
1
G
3
Posts: 105
Reputation: 1,312

Post » Sun Jun 07, 2009 9:22 am

Only use pathfinding actions once, or whenever it's necessary. Using them every tick will cause lag.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sun Jun 07, 2009 1:52 pm

The 'move to...' actions run a very computationally intensive search algorithm over the entire layout. It is completely unecessary to run this search every tick. It'll probably work fine if you pick a random object every 1 second and tell that to move, and it won't tie up the CPU.
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,228

Post » Sun Jun 07, 2009 2:25 pm

It depends on the useage. If you want enemies to pathfind toward you as you move, you should experiment and see how often you need to recompute the path for it to be effective. Unless you are literally moving through numerous hurdles and solids then I can't see why a 'move to' every couple of seconds wouldn't work. It all depends on the useage.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests