Help with reducing Lag

My game shouldn’t lag as much as it does, and i’ve been trying to fix as many things as possible, such as replacing proximity with ray cast, etc. It would be super helpful if someone did a deep dive into my game and could find some problems, and then solutions.
One level that lags a ton is 5-2.
This game has far more problems then this, but i’m hoping it will make the game more enjoyable.

1 Like

So one feature that paid users get is the ability to look at the performance metrics, and see exactly why the game is running the way it is. I am not sure if free users can use this ability. But anyways, here is what I found:

So the game is running at 11 FPS, and the majority of the lag is coming from behaviors. Specifically, Proximity. It may be helpful to use Raycast, but keep in mind that Raycast can also be a primary cause of dropping frames (as you can see by the performance metrics, Raycast is the second highest cause for lag). You want to make sure that the game objects don’t trigger the Proximity or Raycast behaviors too much when it is not necessary, or all at the same time.

Other factors that may cause lag:

  • Multiple objects moving at once
  • Multiple animations playing at once
  • Shared and player objects (multiplayer only), though this affects players in different ways (for example, some players may not experience lag while others will)
  • Objects not expiring after being summoned by an Emit behavior
5 Likes

I’m a little, confused but thanks so much. I can’t find very many things that actually use proximity, So I have no clue what’s causing so much to be used.
I found what caused a lot of proximity, Would mind checking the performance again and seeing if it changed?

3 Likes

Yup, it seems that things have improved. Proximity is still a major reason for lag, but at least we are hitting 38 FPS, which is making gameplay smoother.

3 Likes

I’ve found more proximity, and it’s within every defense. I’m just having trouble translating it to collision.
Basically every “Tower” has a proximity check for different enemy attacks, and the collision doesn’t detect those attacks.

2 Likes

Thank you so much though, my game is running very smoothly now

3 Likes

No problem, I’m glad I could help out! :wink: :+1:

3 Likes

While you’re still helping there’s and object in my game that’s causing an unplayable glitch.
Do you know a way to check and make only on object be in a level at a time, because this object is duplicating itself, and also deleting itself. It seems completely random.
The object is (Tower Choice Controller)

1 Like

Ok never mind this problem is much worse than I though

1 Like

I am looking at the Tower Choice Controller object, and I see no reason why it would be duplicating and deleting itself. So this feels a bit strange to me. Is there any object that spawns the Controller at any point?

1 Like

No, this problem seems to be a glitch of sorts, nothing spawns it, nothing kills it. Yet after every completed level, it bugs and multiplies the (Next Slot) Global.

2 Likes

Well, I do know that numbers stored in the Global behavior are carried to other levels. What might be happening is that the same value is being added to the same Global behavior each time a new level starts.

2 Likes

If you want a ghetto proximity, make a raycast that constantly rotates. Saves my ass every time :slight_smile:

2 Likes

I have a trigger that resets every global at the start of every level.
So even if it is transferring, that should cancel it.

2 Likes

I’m working on my own game that has a lot of lag, are there certain behaviors that don’t cause as much lag? I’m using proximity a lot, what would some good replacements be?

2 Likes

Raycast raycast raycast, I’ve said it before and I’ll say it again. Raycasts are an almost flawless replacement for all proximity and collisions, put 20 of em…100! It doesn’t actually affect the frame-rate that much as long as you know what your doing. It’ll take some tinkering (yeah yeah I know, that word can’t be used by me :laughing:), but I’m sure you can figure it out. And if you can’t I’m here to help.

2 Likes

would you say using 4 raycasts instead of 1 proximity would be more resource efficient? would it be worth it to use 3 or 4 instead of proximity?

2 Likes

Definitely, you could even use more.

1 Like