How can I reduce lag in this game? (SOLVED!)

Me and some peeps are making this epic game: Mall Tycoon. However, 5 minutes into the game it starts running REALLY slow. Like, 3 frames per second. Nothing changes, so can someone dig into the code and see what’s wrong?

2 Likes

Uh, there’s a high chance it’s just your computer…

what type computer do you have?

2 Likes

It doesn’t matter which computer you play it on. If you are aiming for optimization (because that is what you are asking for), you want to make it run smoothly on all hardware (yes, even chrome books).
This is a good question for JR_01, Latif, or PixelPizza. They make fluid games and know alot more about it than I do (seriously, I am very poor at optimization).

2 Likes

Yes, but what you’re running it on plays a big role.

For example, I can’t run any of my bigger projects on my chrome book due to massive lag, but I can on my iMac and it runs a lot smoother.

2 Likes

They simply have more computing power. I get what you mean, and am trying to say that you want your game to have as little code as necessary active at one time so that it works properly on everything.
Now, from a consumer point of view, there is no excuse for if you get a game (even if you are stupid enough to download RDR2 on a chrome book) and it doesn’t run properly. Deficiencies in the product are always the producer’s fault, and this is the point I am trying to get across.

2 Likes

Yeah, I can see where you’re coming from.

2 Likes

Dell. It runs a windows ten, and it’s fairly new. I got it last year.

1 Like

The performance tool is telling me it’s something to do with the proximity, but I haven’t seen anything yet with a quick search. I’ll look more into it later, but to help, what all objects have the proximity behavior? Or any objects with a very large proximity?

2 Likes

It might be the fact that we have 7453 objects 0-0
At least, according to the extract block…

The cash register.
The crates.
The isles.

Extractors doesn’t show how many objects there are, the performance tool shows a lot less so that should be fine. I took a quick look at those objects but didn’t see anything, I’ll look more into it after work.

2 Likes

Okay. It’s saying that for some reason, there are more blocks spawning in then there should. I rechecked and double checked the customer destroy code, and that works. Eventually, I decided that it might be the isles. After all, they’re constantly spawning in the “empty” object after they’re empty. I changed it from a forever to a looping timer.

1 Like

AHA! I found our culprit. It’s either the crate, or the crate spawner…
For some reason, they keep making smart objects when you restock an isle.

2 Likes

@hihilogic, I think I just found the problem.
You have 2 crate spawners on top of each other, this is making a domino effect and double spawning everything in the game. Just delete one of the crate spawners and the game should work normally.

2 Likes

image
After all that… also, I got it to work before you said that :upside_down_face:, but THANK YOU SO MUCH YOU ARE AMONG THE GIFTED!!!

2 Likes

Also, just a heads-up on another helpful tip to reduce lag.
Proximity is one of the top reasons that creates lags in games, so I recommend using them very minimalistic and only when you need to. Your current game should be fine for how you use them, but I recommend to not use them so much in the core mechanic in future projects.

Good luck, o( ̄▽ ̄)ブ

1 Like

Yeah… for the crate, I kind of had to, because in the prox it’s finding the location of the first isle it sees and spawning a fill isle block there, but I totes see where you’re coming from :sunglasses:

1 Like

Well spawning objects so other objects can see them is one way to do it, but really isn’t the only way to do it. For example, when you carry the crate to the shelf, the player can see if it’s holding the crate and also see its next to a shelf. The player can just message the shelf that it was restocked.

But anyways, there’s always many ways to just do 1 thing in programming.
There’s a few other ways I can think of, but just keep in mind the limitations Flowlab has and find ways around them (kinda like other game engines too).

2 Likes

Wouldn’t you have to select one isle to message tho?

1 Like

Yeah but I probably would use a distance bundle so the shelf would accept the message if the player is close. The distance bundle is like a cheap alternative to proximity and without the lag issues.

2 Likes