My game starts lagging if the map is too large

toto8080

Villager
Member
Joined
Feb 26, 2018
Messages
15
Reaction score
0
First Language
German
Primarily Uses
RMVXA
Sorry if I'm posting my thread in a wrong topic, but since Im still new I still need some time to adapt the structure of the site.

I have a huge project, where I make a pathfinder in RGSS3. So my problem is, if my dungeon is big ( for example 100x50 tiles), and the pathfinder event is far enough (ca. 50 tiles), it starts lagging, since the script is running as a paralell, repeat process, and the lagging occurs because it has to compute all the neighnour and parent tiles, so it has a lot to do, which needs time of course.

I found basic AStar pseudos around the internet, and I implemented one in RGSS3, so my script should be full and functional, with all the necessarily functions in it.

Is there a way to make the game smooth, without changing all my dungeons size?
 
Last edited:

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
Alright, let me explain what the lag is.
Lag is, simply put, when the CPU core doesn't have enough time to handle all stacked functions, because it's already handling a different function for too long due to its complexity or due to, if they're multiple, their complexity.
So the only way to prevent that function from making your game lag is to reduce its complexity... Or pass it to another thread via multithreading, so it doesn't interfere with the main thread. Here it depends on one or two things:
1. Ruby itself can do multithreading. But can VXAce's RGSS3 do multithreading? That is a question I don't know the answer to.
2. If RGSS3 can do multithreading, are you capable of using it properly?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Pathfinding scripts lag when you have them on large maps. If you have yours as a parallel process, continually pathfinding, you're causing incredible lag. It's just a bad idea all round imo.
 

toto8080

Villager
Member
Joined
Feb 26, 2018
Messages
15
Reaction score
0
First Language
German
Primarily Uses
RMVXA
Pathfinding scripts lag when you have them on large maps. If you have yours as a parallel process, continually pathfinding, you're causing incredible lag. It's just a bad idea all round imo.
The point of my game is, that the enemy continiusly calculates the optimal path toward the player's character. The script has to be paralell, since the player can move and therefore its position changes.

Do you know any solution, where the game doesnt lag in that case?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
I found basic AStar pseudos around the internet, and I implemented one in RGSS3, so my script should be full and functional, with all the necessarily functions in it.
Assume you could script, why not 'stop' the script after like 10-50 nodes of search and let the game update it first, the continue the search?
Real-time searching is different with simply A* implementation which works better in turn based game
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Do you know any solution, where the game doesnt lag in that case?
No, I don't know a solution, which is why I never implemented it in my Ace mouse script despite many requests from people who didn't realise the issues it would cause.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
The problem is, pathfinding is just too complex for even today's systems. Ever play Dragon's Age (any of them)? The game will often hang 1 - 2 seconds when you select a new location as it is calculating the path for the party. So if it is trying to calculate this for each enemy every second, it will lag, even with today's computers.

The better solution might be to have your parallel process invoke a 60 second wait. The player isn't going to move enough in 60 seconds to affect it too much. Then have it update. That should go a long ways to reducing the lag.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
60 seconds, or 60 frames?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Good catch. I meant 60 frames. Though 60 seconds would probably also reduce the lag :p
 

toto8080

Villager
Member
Joined
Feb 26, 2018
Messages
15
Reaction score
0
First Language
German
Primarily Uses
RMVXA
Sadly, none of the suggested methods are working.

Assume you could script, why not 'stop' the script after like 10-50 nodes of search and let the game update it first, the continue the search?
Because the player is - probably - always moving, the distance is between him and the chasing event is not changing, therefore the big 'calculations', where the script stores the current tiles and parents is always the same size, if not bigger. If I'm not mistaken, this wont help reduce the lag.

The better solution might be to have your parallel process invoke a 60 second wait. The player isn't going to move enough in 60 seconds to affect it too much. Then have it update. That should go a long ways to reducing the lag.
The problem is same as the previous one. Its the same, if the event have to do the 'big work' now, or 60 sec later, the lag is still there.

Guess the only option I left with that I have to reduce my dungeons from 100x50 to 50x50 and hope for the best. :(
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top