Hello, I’m sure you’ve all once encountered this issue, as in the title i am trying to have the character be teleported in front of a NPC, play an animation while anchored, then be unanchored and flung away. What’s happening in the attached video is that
- The CFrame of the character’s HumanoidRootPart is set to be 4 studs in front of the NPC
- The HumanoidRootPart of both the NPC and the Character are anchored, AutoRotate is disabled
- Animation of both plays in it’s entirety
- Character is unanchored
- PlatformStanding on the Character’s Humanoid is enabled
- a VectorForce launches the Character away in the direction the NPC faces
- VectorForce expires, PlatformStanding is disabled
- AutoRotate is re-enabled.
What I have tried so far:
- PivotTo() on the HumanoidRootPart
- SetPrimaryPartCFrame on the character
- Not setting the CFrame at all, instead moving the NPC to be in front of the character
- Not anchoring the Character’s HumanoidRootPart
- Resetting the C0 and C1 values of the RootJoint both after PlatformStanding is disabled and when the character recovers from the Ragdoll state (This works, but only about 50% of the time)
Video
Code Involved
- Code when the player is initially grabbed, details steps 1-2
character = part.Parent
character.Humanoid.AutoRotate = false
character.HumanoidRootPart:PivotTo(NPC.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(180), 0) + NPC.HumanoidRootPart.CFrame.LookVector * 4 - NPC.HumanoidRootPart.CFrame.UpVector * 1.245)
character.HumanoidRootPart.Anchored = true
characteranim = character.Humanoid.Animator:LoadAnimation(anims.backbreakvictim)
characteranim:Play()
characteranim.TimePosition = anims.backbreak.TimePosition
NPC.HumanoidRootPart.Anchored = true
Code when the player is thrown by the NPC, details the rest of the steps
local currentcharacter = character
currentcharacter.Humanoid.PlatformStand = true
currentcharacter.HumanoidRootPart.Anchored = false
local force = Instance.new("VectorForce", currentcharacter.HumanoidRootPart)
force.Attachment0 = currentcharacter.HumanoidRootPart.RootAttachment
force.Force = (NPC.HumanoidRootPart.CFrame.LookVector * 20 + NPC.HumanoidRootPart.CFrame.UpVector * 5) * 500
wait(0.5)
force:Destroy()
currentcharacter.Humanoid.PlatformStand = false
local cor = coroutine.wrap(function()
local connection
connection = currentcharacter.Humanoid.StateChanged:Connect(function(newstate)
if newstate == Enum.HumanoidStateType.Landed or newstate == Enum.HumanoidStateType.GettingUp or newstate == Enum.HumanoidStateType.Freefall then
currentcharacter.Humanoid.AutoRotate = true
--repstorage.event:FireClient(players:FindFirstChild(currentcharacter.Name), "resetrootjointc0andc1")
connection:Disconnect()
end
end)
end)
cor()