What's up with the lag when using a loop command?

For some reason, my game  lags badly when in a middle of this loop.


dnk6CRt.png



I have no idea why this is happening. Also it doesn't seem to move around wheatever if I make it move left or right on the movement route. Is it because I ticked it to be direction fixed?
If there is no wait, the loop will repeat itself every frame. The wait inside the move route don't count, as it is calculated only when the move reach this point (wich it will not), you must add the actual wait event command inside the loop.
Why didn't you just use a custom move route in the autonomous movement section of the event for this?
You've put two movement commands immediately after each other, for the same event, and you haven't used a wait on the first one.  That means the second one will immediately cancel the first one out.


Dalmar is correct.  Use an autonomous move route set to custom, with the following settings:

Code:
Move Right
Move Right
Move Right
Move Right
Move Right
Wait 160 Frames
Script: this.locate(11,15)



then get rid of all the commands in the event and change the trigger back to Action Button (so you're letting the auto movement do the loop rather than doing it yourself with event commands)


That is assuming your goal is to have the event repeat those movements for the entire time you're on the map.
Okay. Thanks, VE, Dalmer, and Shaz. Right now I need to go to bed. I'll try your movement script tomorrow, Shaz.
you can also just set this to run parallel so it does not try to run again until it has finished running. Since you do not have other things in your event this would appear to be the wisest way of doing this because it will be almost lag free... far better than the loop though.
you can also just set this to run parallel so it does not try to run again until it has finished running. Since you do not have other things in your event this would appear to be the wisest way of doing this because it will be almost lag free... far better than the loop though.

Please do not advice to use parallels unless absolutely neccessary and unless you know what you're saying.


Because simply placing the code above into a parallel process will keep the lag unchanged - the lag was caused by the wrong placement of the wait, and that wait would still be placed wrong to prevent the lag of a parallel process, so it wouldn't change anything to use a parallel process here.
I just tested this in a game of mine, and I found that a parallel did reduce the lag a bit. I removed the loop, and made the wait into an actual "Wait" command. this seemed to work nearly lag free and I have a ty desktop. I don't see what the problem with using parallel is @Andar it does not change much in my game. I am guessing that using too many would do something bad, but I have yet to experience this. I was unaware that it is considered a "Last Resort" i thought using a parallel can be quite useful. Such as a music player that changes music once a song has ended etc. I once had a map where there were over 50 parallels and it still worked fine (It was a shooter mini-game) 

Original thread: https://forums.rpgmakerweb.com/threads/whats-up-with-the-lag-when-using-a-loop-command.57128/