HingeConstraints/AlignPosition Loading speed

  1. What do you want to achieve? Keep it simple and clear!
    When players join the game, all HingeConstraints and AlignPosition attachments should be pre-loaded and ready to run (for Hinges, with ActuatorType of Motor with it’s intended AngularVelocity value and AlignPosition attachments to be run with it’s intended MaxVelocity and Responsiveness values)
  2. What is the issue? Include screenshots / videos if possible!
    When a player joins the game, all HingeConstraints and AlignPosition are running in what I’d call ‘slowmotion’ (There are easily over 50 individual Hinges and about 15 AlignPosition constraints) I believe it might have something to do with the amount of these constraints that are meant to be running at the same time, possibly causing a bottleneck or the game prioritizing other game objects to be loaded first (although I’m not sure what that order would be with constraints),

From my testing and observing this issue, it usually takes 1 to 2 minutes for the constraints to load and operate as intended on a stationary device, mobile seems to take 2 to 3 minutes, and when I put my character model close to the parts that are being manipulated by the constraints, they seem to load quicker than the other ones in the distance, which makes me believe that constraints physics are managed on client side.

Here’s a link to a mov video showcasing the issue (couldn’t upload the video on this platform due to the 10MB file size limit):

In Roblox Studio, all of these constraints load instantly without any issues, but that may be because Roblox Studio manages both Server side and Client side traffic, making it load seamlessly.

Extra information I thought could build a better picture of the place:

  • The place itself has around 5k Parts, there are no meshes and a small number of Unions.
  • There are a few scripts re-parenting the attachments for AlignPosition and AlignOrientation between 2 parts every 5 or so seconds to change the direction of where movable platforms are going (I stopped using legacy body movers, and this is the only way I could make the platforms work with Align constraints) (I’m aware that re-parenting objects is quite expensive in terms of resource consumption, but there are only a few scripts doing this)
  • All assets I want pre-loaded are located in folders containing Models, Parts, and unions (alongside other small scripts)
    FolderScreenshot
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I couldn’t find any performance related topics on this platform related to constraints,

I think this has something to do with the priority order of the download queue, so I have tried to use the content provider service (which I have not used before) to try and prompt the constraints to be loaded first with the following local script found in ReplicatedFirst, but it doesn’t seem to be doing what it’s meant to (no errors, so it’s likely doing something unintended and I’m misunderstanding the syntax):

local ReplicatedFirst = game:GetService('ReplicatedFirst') -- getting this service just to ensure it's there
local ContentProvider = game:GetService("ContentProvider") -- getting ContentProvider service 
local MovingObjects = game.Workspace:WaitForChild("AllMovingObjects") -- waiting for the folder containing all assets I want pre-loaded
local Assets = MovingObjects:GetDescendants() -- putting all objects that are constraints including parts they may be parented to in a table

for i = 1, #Assets do -- for loop to go through each asset
	local asset = Assets[i] -- assigning each individual asset to a variable

	ContentProvider:PreloadAsync({asset}) -- executing PreLoadAsync method to pre-load each individual asset
end

repeat wait() until game:IsLoaded() -- waiting for client to load all client side content from the server

I am quite new to development in Roblox (about 6 months in), so any feedback would also be greatly appreciated.

Please let me know if any more information is required, thanks.

Looks to be low acceleration and responsiveness on the properties of the mentioned items.

HingeConstraints have MotorMaxAcceleration and MotorMaxTorque.
AlignPositions have MaxForce and Responsiveness, and if you want snappy movements, RigidityEnabled.

Put bigger numbers to those items (and/or enabled RigidityEnabled on AlignPositions).

Not exactly.

Thank you for your reply,

I have increased AngularVelocity value by 2x (was 0.7, now is 1.4) for HingeConstraints and I have changed the responsiveness value from 10 to 100 and MaxVelocity from 8 to 20 for AlignPositions.

The current values for HingeConstraints are:

  • AngularVelocity: 1.4
  • MotorMaxAcceleration: Inf
  • MotorMaxTorque: Inf

The current values for AlignPositions are:

  • MaxForce: Inf
  • MaxVelocity: 20
  • Responsiveness: 100

I tried RigidityEnabled property and it looks like it just sets the value of the Responsiveness property to max, making objects snap to the destination rather than travel smoothly, which I’d like to avoid if possible.

Here’s a video showcasing the changes:

It looks like the movement of the objects is slow at the start, however once they ‘load’ properly, they seem to be going way too quickly (due to the increase of values) which comes back to my original query - why does it take time for these constraints to build up their speed? It looks to me like their speed at the start is 80% slower, and after a minute or so their speed stabilises and becomes what it’s meant to be.

Like I said, this loads instantly in Roblox studio, but not in the Roblox app, making me consider this being affected by the network ownership (the link you’ve supplied was very helpful),

Is there a way to prompt constraints to be pre-loaded into the game? (like I’ve tried with the ContentProvider service), or is this just how constraints work in Roblox outside Roblox Studio?

It appears your server must be lagging due to multiple parts being simulated. The parts in the first section of your obstacle course are closer to you than the parts in the farther sections, thus setting the network ownership of those parts to your client, and simulate physics there.

If you have multiple constraints, it could cause physics lag on the server, especially if they are constantly moving. I suggest you try using CFrames, although setting your obby to use them may be more challenging to do.

Some problems:
  • Players won’t move with the parts like physics-powered objects would.
  • May appear choppy on the server.
  • More setup to make it behave much like constraints.

My theory is the automatic network ownership takes a while to properly kick in with the physics lag.

Your computer simulates both the server and client in Studio, thus the simulation appearing to be accurate.

There are no ways to “prompt constraints to be pre-loaded into the game” as the constraints themselves are already loaded once a server starts. Physics lag may be the cause, so try utilizing CFrames or other alternatives instead.

1 Like