Server character PivotTo() inconsistencies

As the title suggests, there are some rare/occasional inconsistencies using the character PivotTo() on the server. Simply put, sometimes the character just does not pivot or pivots to the wrong location, which is a huge issue for my game. I was wondering if there is a direct fix to this. I have NOT been able to replicate any of the bugs that involve this error ,and it seems to be completely random.

1 Like

Is there any way that the pivot of your characters are incorrectly changed as you run :PivotTo()? Or maybe physics is somehow incorrectly interacting with your :PivotTo()?

1 Like

No, pivots are correctly scheduled appropriately. There are also checks to ensure the pivots succeed but rare cases the bugs somehow bypass these checks.

1 Like

provide proof please :slight_smile:

or even better, some recorded context

edit:
i cant rlly tell you much without context okay… I MAY help with context ofc :wilted_flower:

1 Like

pivotTo is not reliable and I recommend against it

  1. use setprimarypartcframe, which is ‘deprecated’ (bs)
  2. use cframe with parts welded/connected to humanoidrootpart (this is best for your situation imo)

edit: oh shoot

Simply put, sometimes the character just does not pivot or pivots to the wrong location, which is a huge issue for my game. I was wondering if there is a direct fix to this. I have NOT been able to replicate any of the bugs that involve this error ,and it seems to be completely random.

probably a stretch, but sounds like you’re setting it at a constant rate? in a runservice loop? and you said there’s random spikes of the issue? then maybe you aren’t utilizing deltatime properly

https://www.construct.net/en/blogs/ashleys-blog-2/using-lerp-delta-time-924
a = lerp(a, b, dt) suffices (no need for a = lerp(a, b, 1 - f ^ dt))

eedit: start = lerp(start, goal, speed * 60 frames_per_second * dt seconds_per_frame

2 Likes

When i want to move the player i just move its humanoid root part and it works

1 Like

Curious, why are you against PivotTo()?

2 Likes

Only reason I could think of would be that the RootPart is basically the center of the character, PivotTo() will use the Character’s PrimaryPart, which I believe is the head

Edit: I just rechecked and the PrimaryPart is the RootPart in R15 (Head in R6)

1 Like

i linked an example
sure it works most the time
but i find setprimarypartcframe or .cframe to work perfectly

1 Like

no thats not the reason you can easily just change the primarypart

1 Like

Context is I’m using PivotTo() on a player character model >> RARE cases where players reported not teleporting properly.

1 Like

The pivot is run once, then there’s a check for correct pivot with a tolerance of 5 studs, it continues trying to pivot in 0.2s intervals + frame delay up to 15 times (~3 seconds).

1 Like

After diving deeper into the problem and receiving some more information from players, it seems as if the bug is being caused by a huge lag spike right at the moment of teleports, causing the client to override the player’s position on reconnect (my theory). Pivot problems are completely RANDOM with no obvious pattern to them, however from 2/3 reports, this is all I can go off from.

1 Like

oh man set the position of the player on server and client

-- server
playerInfo.currentValidPosition = newPosition
---- this playerInfo.currentValidPosition is changed only if the server is manually teleporting 
---- the player or if the change in the clients position between two 'ticks' (maybe 0.2s) is valid
---- via raycasting and distance checking (on server)

---- you can also uncomment the line below if it doesnt end up being choppy.
---- shouldn't though, because server position is replicated to the client almost the exact time they recieve the clientSetPosition remote
-- playerCharacter.HumanoidRootPart.Position = pos

clientSetPosition:FireClient(player, newPosition)

-- client
clientSetPosition.OnClientEvent:Connect(function(pos)
    localCharacter.HumanoidRootPart.Position = pos
end)

theres a few things in this code

  • there is server authority
  • i do not use pivotTo, i absolutely do not trust it
  • you can set the position twice (server + client) for guarantee and to eliminate the bug. but rationally you would only do server

typically you would’nt even need the remote- setting position on server usually suffices. in your case it apparently doesn’t.

this is not normal.

memory leak? heavy computation?
go through your game and wrap every computationally-heavy function (loops, and wtver else) with debug.profilebegin(title) and debug.profileend()
it doesn’t seem like a memory leak- memory leaks are usually gradual decreases in frames. patterns sounds like its an issue with one of your games functions. or maybe map idk maybe theres a bunch of parts in 1 spot.

if you send me a copy of your games client-side i can go through it and find the bug for you.

also this is not a good band-aid at all


in sum, don’t use pivotTo, and also try setting position on client w/ server authority

1 Like

There’s no memory leak or heavy computation in the game. I’ve put in a lot of effort to optimize the game as low-level as possible (btw 2/3 meant 2 or 3, not 2-thirds of all reports). I am going through with client verification, too. For any teleports, I will just be sending a client teleport request through my remote manager. Thanks!

2 Likes

hows it going? is the issue resolved? do u have a video of the issue

1 Like

I have the functionality set up but I haven’t rolled it out to live servers yet. There are a couple of other bugs that I’ve delegated to testing. No additional video of the issue or reports. I have other work/projects, so I will update the servers on the next rolling update patch!

2 Likes