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 am trying to create a ledge traversing system where when the player initiates a certain key, they will teleport to the closest “ledge” and be able to move left and right accordingly.
I’m trying to create something similar to the video below other than the fact that the ledge climbing is initiated by pressing a certain key. Demo
What is the issue? Include screenshots / videos if possible!
I am unsure of what to do after finding the closest edge to the player. Many of the solutions I read refer to “Wall Climbing” and consist of casting rays which I don’t think really helps in my situation.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
The blue circle in the image above represents the closest edge to the player.
That is practically as far as I have gotten and am looking for advice on how to create left and right movement on the ledge and changing faces on the same ledge and other ledges. I can provide any code snippets if needed, thanks!
I’m not too sure using MoveTo will solve my problem as the character is not walking to a point they are hanging on a ledge which would require body movers or manually setting the position as seen in the picture below. Nevertheless, I need a way to detect those position to move to on the ledge. Also I’m sorry but was your response created by ChatGPT…
When the player hits a ledge, grab their position (origin). Weld them to the ledge, from origin position to ledge.
When they hold A or D you can then change the cframe of the weld.
When they press space or hit the edge, unweld
And if you want to be really cool you just grab the ledge’s vector and length, and just limit movement to the difference between origin, ledgemi
n and ledgemax
I’m more concerned on how I would find a line of traversal for the ledge. Basically, how would I detect the next left or right position from the player’s current position on a ledge?
That means by taking both ends, we can calculate a vector in the direction of the ledge.
local ledge = workspace.ledge
function getEndPoints(ledge)
local center = ledge.CFrame
local p1 = workspace.a
local p2 = workspace.b
-- p1.CFrame = ledge.CFrame * CFrame.new(ledge.CFrame.p, ledge.CFrame.LookVector) * CFrame.new(length/2,0,0)
local orientatedVector = ledge.CFrame:VectorToWorldSpace(Vector3.new(ledge.Size.X,0,0)) --This is the vector you want
p1.CFrame = center+orientatedVector/2
p2.CFrame = center-orientatedVector/2
end
getEndPoints(workspace.ledge)
Thats a good solution, but if you want to do something easier and less advanced, i suggest a simple BodyVelocity in the HumanoidRootPart that when you press A or D it activates.