Discuss Scratch

vinelard
Scratcher
12 posts

How to fix the lag in my game?

Hello

I am making a top down game, I added movement and collisions with youtube tutorials. The first time I tried it went smoothly, but I remade the game from scratch and now its super laggy. Please help, I have no idea what I am doing.
asphalt10underground
Scratcher
100+ posts

How to fix the lag in my game?

Please share your project so that we know exactly what the problem is
vinelard
Scratcher
12 posts

How to fix the lag in my game?

asphalt10underground wrote:

Please share your project so that we know exactly what the problem is


Here is a link to the project: https://scratch.mit.edu/projects/1314681536
wisco11
Scratcher
100+ posts

How to fix the lag in my game?

There is no lag for me. It may be an issue with your computer. try a network latency test.

Also, I was JUST WORKING ON THE SAME KIND OF PROJECT!!!! thank you for sharing your code, now I understand why mine was not working. I had the collision detection in the wrong list.
vinelard
Scratcher
12 posts

How to fix the lag in my game?

wisco11 wrote:

There is no lag for me. It may be an issue with your computer. try a network latency test.

Also, I was JUST WORKING ON THE SAME KIND OF PROJECT!!!! thank you for sharing your code, now I understand why mine was not working. I had the collision detection in the wrong list.

I have a feeling it was my computer, its a pretty cheap laptop. But I am glad it runs normally for you. I might double check on the library computer if it runs the same. I'm not 100% sure if that's the cause. Also what a coincidence. I will check out your project.
vinelard
Scratcher
12 posts

How to fix the lag in my game?

I added obstacles and the lag is even worse now omg
Inquisitive_Rabbit
Scratcher
43 posts

How to fix the lag in my game?

Hello! I've found out why the obstacles are lagging. It's because of the

wait (0.5) secs

block in the “Collision” custom block. This block is keeping the movement scripts from running for half a second, so the best way to fix the lag is to remove that block.

But of course that makes the player's health go down too fast. To solve that problem, replace the -10 in the

change [HP v] by (-10)

block with a smaller value. To keep the same speed you had before, I recommend using the value -0.66.

Hope that helps
vinelard
Scratcher
12 posts

How to fix the lag in my game?

Inquisitive_Rabbit wrote:

Hello! I've found out why the obstacles are lagging. It's because of the

wait (0.5) secs

block in the “Collision” custom block. This block is keeping the movement scripts from running for half a second, so the best way to fix the lag is to remove that block.

But of course that makes the player's health go down too fast. To solve that problem, replace the -10 in the

change [HP v] by (-10)

block with a smaller value. To keep the same speed you had before, I recommend using the value -0.66.

Hope that helps

Thank you so much for the advice! I will give that I try and report back if its still lagging. But you are right, that should hopefully really fix it.
Clause_Thebest-1
Scratcher
1 post

How to fix the lag in my game?

Hello i was following a tutorial and when a finished it was super laggy can i get help with this? https://scratch.mit.edu/projects/1351484142
Inquisitive_Rabbit
Scratcher
43 posts

How to fix the lag in my game?

Hi! I think I've found the issue.

The “Physics” custom block contains a repeat loop coded to run 6 times. We want those repeats to all take place at the same time, but Scratch thinks those 6 repeats should occur over 6 separate frames. In effect, that unnecessary waiting is making the project run at one-sixth the speed it should.

To make that happen, right-click the “Physics” custom block, click “Edit,” and tell the block to “run without screen refresh.” That will make it run at the speed we need it to.
TheRAFY
Scratcher
10 posts

How to fix the lag in my game?

I don't see any lag. Maybe because of your hardware. Fix those variables to be non decimal numbers and remove some effects because maybe that will work.
Sammies123333
Scratcher
1000+ posts

How to fix the lag in my game?

Clause_Thebest-1 wrote:

Hello i was following a tutorial and when a finished it was super laggy can i get help with this? https://scratch.mit.edu/projects/1351484142
It's probably better to make your own topic if you need help

also alan becker detected?

Powered by DjangoBB