Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to align player against a wall depending on which surface the player is facing?

Asked by 4 years ago

I'm making a climbing script that allows the player to climb certain walls in the game. I am trying to make the player orientation so it's facing the building. Example

Now here’s the reason why my question is awfully long, you can’t just have the player face towards the center of the building, this is incorrect, instead you need them to be aligned with the wall. The easiest way this can be done is through raycasting.

So using FindPartOnRayWithIgnoreList it is possible to get the surface direction easily.

local ignoreList = {}
local characterDes = Char:GetDescendants()
  for i, instance in pairs(characterDes) do
    if instance.ClassName == "Part" then -- is it a part the ray could hit
      table.insert(ignoreList, instance) -- Add the part to the ignoreList
    end
end

local surfaceray = Ray.new(character.HumanoidRootPart.Position, character.HumanoidRootPart.Position+[CLIMBABLE_PART_HERE].Position)
local part, position, surface = workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)

Okay now that you've caught up with me, how would I use this surface variable to CFrame my character through the use of BodyGyro? I can't really think of any efficient way to use this veriable. Could someone help me understand the maths behind orienting the player using this?

2 answers

Log in to vote
0
Answered by 4 years ago

found the answer nvm, thanks for nothing :')))

0
Can u explain how u did ? AfraiEda 8 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Can u explain how did u manage to solve it ? Because i'm searching the same thing and i'm stuck and i cant figure it out

0
were you able to figure it out? sorry i wasn't active on here message me on roblox if you still need help with this. player178 15 — 3y

Answer this question