AlignPosition Heavily Delayed

Another AlignPosition issue (feels like I run into issues frequently with these guys…)

I have an object that I am trying to move to be in front of my character. I want this object to be somewhat loose (so that it may rotate freely and collide with objects that can mess up its trajectory).

This is fine… Provided you wait a solid 30 or so seconds. The AlignPosition object has the right position, but the object does not move for a long time, regardless of whatever parameters it has. I can set this thing to have a gazillion in max force, velocity, 200 in responsiveness, or nada in all three, nothing changes. Size of the object does not matter, neither does mass.

Does anyone know why this is occurring? I will attach a video, a studio file, and the script itself (ignore the terrible naming conventions and conventions in general - this is just me messing around for a lackluster prototype).

Video:

Studio File:
public.rbxl (48.6 KB)

Script (local script in StarterCharacterScripts)

wait(5)
local thing = game.Workspace.thing;
local attach = thing.Alignment;
local pos = thing.AlignPosition;
local ori = thing.AlignOrientation;
print("in a sec")
wait(1)

local runservice = game:GetService("RunService");

local humanoid = script.Parent.Humanoid;
local character = game.Players.LocalPlayer.Character;
local humanoidrootpart = character.HumanoidRootPart;

local bruh = Instance.new("Attachment",game.Workspace.Terrain);
pos.Attachment1 = bruh;

humanoid.Died:Connect(function()
	print("h")
	runservice:UnbindFromRenderStep("haha");
end)

local sizeZ = thing.Size.Z/2;


function h()
	pos.Enabled = true;
	ori.Enabled = true;
	task.wait()
	pos.Enabled = false;
	ori.Enabled = false;
	task.wait()
	pos.Enabled = true;
	ori.Enabled = true;
	runservice:BindToRenderStep("haha", 300, function()
		if((attach.WorldPosition - (humanoidrootpart.CFrame+Vector3.new(0,0.85,0)).Position).Magnitude > 7) then
			print((attach.WorldPosition - (humanoidrootpart.CFrame+Vector3.new(0,0.85,0)).Position).Magnitude)
			runservice:UnbindFromRenderStep("haha");
			pos.Enabled = false;
			ori.Enabled = false;
			wait(6)
			h();
		end
		bruh.Position = (humanoidrootpart.CFrame+Vector3.new(0,0.85,0)):ToWorldSpace(CFrame.new(Vector3.new(0,0,-5))).Position;
		attach.Orientation = humanoidrootpart.Orientation;
	end)
end

h();
1 Like

You could just use parts.

  1. PositionPart - An invisible part in from of your character (Welded to the HRP)

  2. UniversalPart - Another invisible part that is connected to the PositionPart with a UniversalConstraint. Add a WeldConstraint and set Part1 to the UniversalPart.

Now, clone your Object and position it to the UniversalPart CFrame. Connect it to the Part0 of the WeldConstraint.

The Object will rotate freely as you move around.

If you want other movements you can try out other Constraints. Like maybe an invisible rope!

I’m not quite sure this would achieve my longterm goal with this system. Yes, it would be nice for the rotation, but it would unfortunately fail in other goals → like the “looseness” of interaction.

For example, here’s this video (again, I had to wait for anything to happen):

(This is intended behavior that I’d like to keep, for clarification)

I noticed that it was a very long delay. And frequently reoccured.

I also somehow got the box behind me and was being pushed around the box at high speeds.

Yeah, the pushing and the box being behind you are… other bugs that I’ll have to sort out. But that’s less of a concern for now.

Check out the other Properties as well. They make huge differences in how the Align Constraints work.
AlignPosition | Documentation - Roblox Creator Hub
AlignPosition | Documentation - Roblox Creator Hub

As stated above, I have manipulated the properties in many different ways and produced no visible differences in the initial delay.

Here is a video posted a month ago.

It looks to be exactly what you want:

I have reviewed that video and while it is useful, it still does not explain what is wrong with my initial code.

Imagine that I port this prototype to a more functional system with other components added to it. I would really like to know what is causing the issue instead of relying off of example code, especially if it bugs out again. In my eyes, my script does something relatively similar to their video (give or take some portions), and therefore is not very useful in diagnosis.

I understand if this may come off as a little unnecessary or ignorant, but I simply just wish to learn more about this issue.

the issue is the client isn’t taking control of the block’s physics networking wise until the engine figured out whats supposed to be happening.

this fixed the issue, as a script within serverscriptservice

game.Players.PlayerAdded:Connect(function(plr)
	workspace.thing:SetNetworkOwner(plr)
end)

Network Ownership is the behavior in which Roblox allocates physics calculations. If a block is not “owned” by a client, its calculated on the server until the server determines if it should be calculated by a client, typically by using distance and recognizing attachments and physics – which is slow and causes rubberbanding in unusual circumstances. This is an unusual circumstance. Set the block’s network owner via the example above to the player who is taking control of it. This is required to be done on the server.

https://i.gyazo.com/1de9c94b7787835a8949d5f290e2ebbc.mp4

also, your code is really messy, consider cleaning it up, and the way its doing any checks cause some latency of its own, but the actual physics latency youve been experience is fixed with the above.

2 Likes

Ah! Network Ownership, my worst enemy.

Thank you for the heads up, fixed the issue.

Also, yeah, the code is quite messy. I’ll clean it up after a few more bug checks. Have a good one!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.