As title specifies. Working on a ledge grab feature where i need to move the HumRoot next to the face of the wall they are facing.
The issue:
Depending on the global orientation of the wall, character seems to be repositioned and reoriented completely differently.
I cannot get my head around it.
Video:
Code:
function movement:ledgeGrab(ray_result, dt) -- under freefall condition
if self.isClimbing == false then
self.isClimbing = true
local part = ray_result.Instance
local normal = ray_result.Normal
print("part: " .. part.Name)
print("normal: " .. tostring(normal))
-- get humroid root part position
local CharPosX = Character.HumanoidRootPart.Position.X
local CharPosY = Character.HumanoidRootPart.Position.Y
local CharPosZ = Character.HumanoidRootPart.Position.Z
partPosX = part.Position.X
partPosY = part.Position.Y
partPosZ = part.Position.Z
partSizeX = part.Size.X
partSizeY = part.Size.Y
partSizeZ = part.Size.Z
if normal == self:GetNormalFromFace(part, Enum.NormalId.Right) then
print("Face RIGHT")
local newCFrame = CFrame.new(partPosX + partSizeX / 2 + 1.05, (partPosY + partSizeY / 2) - 1.009, CharPosZ) * CFrame.Angles(0, math.rad(90), 0)
Animate.LedgeClimbTrack:Play()
Animate.LedgeClimbTrack:AdjustSpeed(.25)
Character.HumanoidRootPart.CFrame = newCFrame
Character.HumanoidRootPart.Anchored = true
print("CharPosX: " .. Character.HumanoidRootPart.Position.X)
wait(.5)
Character.HumanoidRootPart.Anchored = false
--self:ledgeClimb(ray_result, dt)
Animate.LedgeClimbTrack:Stop()
end
end
end