Hello,
I have been working on my own player movement script and at one point I have to Anchor the HumanoidRootPart to get a desired effect, and when finished I unanchor the HumanoidRootPart. I am using the Humanoid:Move() function with the relativeToCamera boolean set to true to move the player.
My script works fine up until this point. After Anchoring/Unanchoring the HumanoidRootPart the Humanoid:Move() function starts behaving abnormally by giving the wrong values (Increased values [Speeding up the player], Decreased values [Slowing down the player], and/or just plain wrong direction); however, this only happens when near other objects.
I have already tried the following:
- Setting HumanoidRootPart.Velocity to 0 before and after Anchoring/Unanchoring respectively.
- Setting Humanoid.WalkSpeed to 0 while anchored
- Setting Humanoid.PlatformStand to true before Anchoring and to false after Unanchoring
- Checking to see if any parts of the Character are beyond the model and colliding with other objects
Humanoid.MoveDirection displays/prints out the same exact Move Directions as it was before Anchoring the HumanoidRootPart, but the character isn’t moving as it was previous to it.
This is the code I am using for Movement
--h = Humanoid
--Hold_W,A,S,D are activated/deactivated on the keyboard presses
runService.RenderStepped:Connect(function()
if rootPart.Anchored then return end
local forward = 0
local sideways=0
if Hold_W and not Hold_S then
forward=-1
elseif not Hold_W and Hold_S then
forward=1
end
if Hold_A and not Hold_D then
sideways=-1
elseif not Hold_A and Hold_D then
sideways=1
end
h:Move(Vector3.new(sideways, 0, forward), true)
end)