You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want a working ledge climbing system with the option to move left and right.
-
What is the issue? Include screenshots / videos if possible!
When my character grab the ledge the character rotate in the opposite direction
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I just found how to rotate the character using CFrame.Angles()
but is not working
The system basically works by creating a part and putting it alway a bit further than the HRP position and the player tweens to it every time he press A or D.
If need i can provide code snippets
1 Like
Please post your code and some screenshots explaining what happens and what you want to happen
Here my code
Player:GetMouse().KeyDown:Connect(function(D)
if D == "d" then
if onLedge and (EndPointB.Position - EndPointC.Position).magnitude > 1 then
EndPointC.Position = EndPointC.Position - Vector3.new(2,0,0)
local newcf = EndPointC.Position
local goal= {Position = newcf}
script.Parent.HumanoidRootPart.Anchored = true
local tweenService = game:GetService("TweenService")
local tweeninfo =TweenInfo.new(
.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0)
local tween = tweenService:Create(HumanoidRootPart, tweeninfo, goal)
tween:Play()
wait(0.3)
end
end
end)
Player:GetMouse().KeyDown:Connect(function(D)
if D == "a" then
if onLedge and (EndPointA.Position - EndPointC.Position).magnitude > 1 then
EndPointC.CFrame = EndPointC.CFrame + Vector3.new(2,0,0)
local newcf = EndPointC.CFrame
local goal= {CFrame = newcf}
script.Parent.HumanoidRootPart.Anchored = true
local tweenService = game:GetService("TweenService")
local tweeninfo =TweenInfo.new(
.5,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0)
local tween = tweenService:Create(HumanoidRootPart, tweeninfo, goal)
tween:Play()
wait(0.3)
end
end
end)
--//FUNCTIONS//--
function vectorToWorldSpace(cframe, vector)
local v = cframe:VectorToWorldSpace(vector)
return Vector3.new(math.abs(v.X), math.abs(v.Y), math.abs(v.Z))
end
--//RAYCASTING//--
while task.wait() do
local rayOrigin = Head.Position
local rayDirection = Head.CFrame.LookVector * 1.2
local rayParams = RaycastParams.new()
local rayResult = workspace:Raycast(rayOrigin, rayDirection, rayParams)
if rayResult and char.Humanoid.FloorMaterial == Enum.Material.Air then
char.Humanoid.AutoRotate = false
local hitpart = rayResult.Instance
HumanoidRootPart.Anchored = true
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame * CFrame.Angles(math.rad(180),0,0)
onLedge = true
animation:Play()
HumanoidRootPart.CFrame = CFrame.lookAt(HumanoidRootPart.Position, hitpart.Position)
local center = hitpart.CFrame
local orientatedVector = hitpart.CFrame:vectorToWorldSpace(Vector3.new(hitpart.Size.X,0,0))
local headY = Head.Position.Y
local headX = Head.Position.X
hitpartvalue = hitpart.Position
EndPointA.CFrame = center+orientatedVector/2
EndPointB.CFrame = center-orientatedVector/2
print(hitpartvalue.X)
local EndPointAX = EndPointA.Position.X
local EndPointAZ = EndPointA.Position.Z
local EndPointBX = EndPointB.Position.X
local EndPointBZ = EndPointB.Position.Z
local EndPointCX = hitpart.Position.X
local EndPointCZ = hitpart.Position.Z
EndPointA.Position = Vector3.new(EndPointAX,headY - 2,EndPointAZ) + Vector3.new(0,0,-hitpart.Size.Z/2)
EndPointC.Position = Vector3.new(EndPointCX,headY - 2,EndPointCZ) + Vector3.new(0,0,-hitpart.Size.Z/2)
EndPointB.Position = Vector3.new(EndPointBX,headY - 2,EndPointBZ) + Vector3.new(0,0,-hitpart.Size.Z/2)
end
end
I want the character to be “watching” the ledge and not rotating to the opposite direction.
1 Like
Have you tried something like
local newcf = EndPointC.CFrame * CFrame.Angles(0, math.pi, 0)
?
1 Like
I tryed; the character rotates correctly but for some reason it slide down. I think the only solution is to rotate the torso in the animation and if that either dosen’t work sadly i’m gonna have to find another way to make my climbing system.