WHY is my game lagging?

Hey guys!

As you might know, I’m re-making Vehicle Battlefield. I’m upgrading the graphics, FX, and much more, but something today completely stopped me in my tracks. THE GAME IS LAGGING IMMENSELY! It’s REALLY laggy, seriously, I can’t even complete animations on time. I don’t know why, I checked all of my recent code.
If you think you know why, I’ll send the game link. It’s supposed to be released at New Year, so I can’t share it with the world just yet. Please, HELP!

-Ember.Y

3 Likes

I’ll look into it now.

Maybe you have too many objects in your game?

Yeah, it’s at 26 frames for my computer…

I think it’s because of all those proximities in the undergrowth, and in the enemy turrets.

Instead of using proximity, you can make globals for the player’s X,Y coordinates, then just use the distance bundle to see how close the player is. (use a filter, if you want it to act like proximity. Filter: <100 will output when the player is in a 100 pixel radius from the object.) This will reduce a lot of lag.

Distance bundle:

{"data":{"behavior":{"v":"2","nodes":[{"inputCount":2,"outputCount":1,"name":"Distance 1.0","behaviorType":"logic.NodeGroup","x":-270,"y":-656,"group":"","id":"ea2a6ad932240e4d","notes":null,"n_o":null,"isMenuItem":false},{"expression":"b-a","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":1,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":90,"y":192,"group":"ea2a6ad932240e4d","id":"ea2a6ada7eb8b048"},{"expression":"b-a","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":1,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":90,"y":32,"group":"ea2a6ad932240e4d","id":"ea2a6ada1043824a"},{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-270,"y":64,"group":"ea2a6ad932240e4d","id":"ea2a6adaf6845f43"},{"expression":"Math.sqrt(Math.abs(A*A) + Math.abs(B*B))","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":1,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":270,"y":96,"group":"ea2a6ad932240e4d","id":"ea2a6ada5bcf1849"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-90,"y":160,"group":"ea2a6ad932240e4d","id":"ea2a6adaa79c2e4c","targetId":0,"prop":"y"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-90,"y":-32,"group":"ea2a6ad932240e4d","id":"ea2a6adaeab6bf41","targetId":0,"prop":"x"},{"inputCount":1,"outputCount":0,"name":"Bundle Output","behaviorType":"logic.NodeGroupOutput","x":450,"y":128,"group":"ea2a6ad932240e4d","id":"ea2a6ada32ad524a","notes":null,"n_o":null,"portId":"ea2a6ad932240e4do0","tag":"dist.","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":64,"group":"ea2a6ad932240e4d","id":"ea2a6ada2f014041","portId":"ea2a6ad932240e4di0","tag":"X","dataType":2},{"inputCount":0,"outputCount":1,"name":"Bundle Input","behaviorType":"logic.NodeGroupInput","x":-90,"y":256,"group":"ea2a6ad932240e4d","id":"ea2a6ada199cec4b","portId":"ea2a6ad932240e4di1","tag":"Y","dataType":2}],"links":[{"input_id":"ea2a6ada5bcf1849i1","output_id":"ea2a6ada7eb8b048o0"},{"input_id":"ea2a6ada5bcf1849i2","output_id":"ea2a6ada7eb8b048o0"},{"input_id":"ea2a6ada5bcf1849i0","output_id":"ea2a6ada1043824ao0"},{"input_id":"ea2a6adaeab6bf41i0","output_id":"ea2a6adaf6845f43o0"},{"input_id":"ea2a6adaa79c2e4ci0","output_id":"ea2a6adaf6845f43o0"},{"input_id":"ea2a6ada32ad524ai0","output_id":"ea2a6ada5bcf1849o0"},{"input_id":"ea2a6ada7eb8b048i0","output_id":"ea2a6adaa79c2e4co0"},{"input_id":"ea2a6ada1043824ai0","output_id":"ea2a6adaeab6bf41o0"},{"input_id":"ea2a6ada1043824ai1","output_id":"ea2a6ada2f014041o0"},{"input_id":"ea2a6ada1043824ai2","output_id":"ea2a6ada2f014041o0"},{"input_id":"ea2a6ada7eb8b048i1","output_id":"ea2a6ada199cec4bo0"},{"input_id":"ea2a6ada7eb8b048i2","output_id":"ea2a6ada199cec4bo0"}]}}}
1 Like

Proximity is very laggy, I agree.

yeah spamming proximities will always be laggy

raycasts also lag and there is a way to do them with math (i have many examples) so if you need raycasts with math to reduce lag i gotchu

2 Likes

That’s cool! I’ll definitely be using that later lol

1 Like

Dang, ok. Thanks.

Yeah, when I found Proximity, I thought: “Oh, this is useful, this can fix all of my problems.” Then, without realizing it, I started using it in mostly everything.


LOL.

I switched out one Proximity for a raycaster and another for your distance bundle, Flying Fajita, the game works well now. Thanks a bunch!

1 Like