BodyMovers become slow when there are a lot of them

Velocity moves slower and gyros turn slower. I’ve been looking back into Laser Tanks and this is a problem that I tried to fix by setting the owner to the client, but that didn’t fix it, so I went into studio and played it. With one gunship tank, it zips across the map quickly. When I spawn 5 more and control them all at the same time, the magnitude of the velocity is the same, but they move horribly slow. I multiplied the speed by 10 and that brought it up to normal. Is there something I can do about this? Is the cause known/being fixed/it’s a feature not a bug?

2 Likes

Pretty sure this is happening because physics are not delta time-based.

https://d3v55qvjb2v012.cloudfront.net/fcxN/2016/01/11/01/20/cDVXVYhk9k/sc.mp4?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kM3Y1NXF2amIydjAxMi5jbG91ZGZyb250Lm5ldC9mY3hOLzIwMTYvMDEvMTEvMDEvMjAvY0RWWFZZaGs5ay9zYy5tcDQiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE0NTI1NjE2MTV9fX1dfQ__&Signature=XutrkJNLGBUEanjjL4J7U-7q0BQk3EtndRXnG1S9ZJlwcHaSsFzuEKJ~8jeP~YR2p5kXwjs1WCIhBnfBraTDEjBDSQgyba2-1w9OXpAht0wwSiI315bVIVar7iQ0A5tY-FDa2D5XYgkJNwvV4bosHStVQriknvs4bOFVnw78sf4_&Key-Pair-Id=APKAI4E2RN57D46ONMEQ

1 Like

Is there anything I can do or any alternative to improve this? I tried setting the owner to the client and that made everything appear in the wrong places and didn’t affect the movement.

@1waffle1 - Can you please upload a simplified model that exhibits this problem? We will take a closer look and try to determine the cause of the performance hit.

Thanks!

Just drop this in StarterPlayerScripts

It makes bricks that follow your mouse when you hold it down. They move to your mouse and then stop when either you let go, they are already close enough to the target, or the target stops changing and they arrive.

A new brick is spawned every render step. In the first few seconds, all is well. The bricks fly at a good speed toward your mouse. A few seconds later, now you can pass them at walking speed.

Something worth mentioning is that the value of wait() starts to become extremely large. The rendering speed is still fine and you still walk at the same speed - there’s no visible lag, but the actual simulation speed is like 0.1 FPS and worse, and the parts appear to become slower the greater the value of wait() (not sure if it is a direct linear correlation though.)

Thanks @1waffle1. We’ll take a look and see what we can do.

I can’t make that script to work. Can you please upload a level that reproduces this bug?

Also: how many bricks do you need to spawn before you see slow downs? Just making sure it’s not a performance issue due to too many simulated objects.

Thanks.

The slowing down seems to be proportional to the number of parts and not caused by some number being reached. I tried uploading a place from studio and it crashed and now I’m trying to do it on the website and nothing is working because everything is timing out and roblox doesn’t want me connecting to it anymore right now. I’ll try again once it stops being angry.

Okey, thank you! Looking forward to the upload!

chefdeletat, do you mind me asking what your roblox profile is? I don’t think I’ve seen you before. :open_mouth:

@1waffle1: Thanks for the upload! I’ll be investigating

@1waffle1: This level is an empty level with some scripts. Can you provide instructions or otherwise make it easy to reproduce?

Go in studio and press play with character. A part spawns every render frame. Click and hold to make all of the parts follow your mouse. They should move at a constant speed of 50 studs/sec (you walk at 16) but eventually they slow down. You will notice just how much they’ve slowed down when you start walking faster than them, which should only take a few seconds.

This seems to be a performance issue due to the sheer number of blocks that are spawned. Can you reproduces your issue with 1 block behaving differently from 2 blocks?

In Laser Tanks, there is one bodyvelocity (and bodygyro) object per tank. There can be up to 11 tanks per player and 12 players, but that is the max; there’s usually around say 40 tanks in the server. print(wait()) sometimes gives over 10 seconds per frame. Two parts probably won’t be different from 1 because two parts don’t really make the game slower than 1. The slowness in speed is related to the slowness of the game.

That makes sense. This issue is related to the FPS of the game. If the FPS is too small, the BodyMovers will move objects more slowly because well the game can’t handle the load (this happens when the FPS is ‘REALLY’ slow because otherwise we would have synchronization issues). I would say try to reduce the load on your game.

If you upload a level we can run a performance analysis and identify the issues.

1 Like

How does your performance analysis work? Is it something I can do online/something other developers can run in their own games? Just looking at the dev console, I know what part of my game is causing the majority of the lag and the little color label next to the script is a frightening color with a high percentage:

Unfortunately our game profiling tool is not accessible to the devs - it requires access to the code base.