How can I orient player's character using raycast Normal?

Making a wall climbing system and am trying to orient the player perpendicular to the wall using the raycast normal. I don’t know how to do this. How would I go about doing this?

2 Likes

I’ve made a system similar to this before, I recommend using both AlignOrientation and AlignPosition inside a parent Part and manipulating that part’s position while climbing so the character’s climbing movements update automatically. To get a position from raycast normals, you can use CFrame vectors (such as UpVector and RightVector) and the Vector3:Cross method, which finds a vector perpendicular to both the UpVector and LookVector. You can then update the parent Part’s position from there.

3 Likes

What do you mean by a “parent part”. I previously was using AlignPosition and AlignOrientation for the wall climbing system, but the movement didn’t work because I was more or less welding my player’s character to the wall. This post: How can I attach character to wall in wall climbing script? details my struggles and the solution is what I’m now doing. So, my question is what is a “parent part” and how would I implement it in my code?

2 Likes

I meant a part created in your script by Instance.new that would hold both constraints. This would be the “manager part” in a way and would essentially control all movement. You’d position said part using the methods I told you about rather than positioning or “welding” the character directly. As for the solution in the linked post, I don’t recommend using tweening or anchoring the root part at all, this can cause for very choppy movement and messed up animations. Using strictly these constraints makes it much more smooth.

Alright. How would I check the player’s movement? Would I use a RemoteEvent or using the Humanoid Move Direction property. I’m also confused about how I would use the “manager part” to control the player’s movement. Would I weld the player to the manager part, or would I set the player’s character to the position of the manager part + an offset?

Are you trying to make both mantling and ledge scaling (left and right movement on the ledge)? Or just mantling where the player jumps up onto a ledge and hangs there?

if you wanted to integrate ledge scaling, you would not need to use welding at all. If you wanted to control the part’s movement through a RemoteEvent for security, you can. But it’s not completely necessary. The player would be attached to the manager part through an AlignPosition constraint and two attachments. One attachment being inside of the character’s RootPart (acting as Attachment0), and the other being inside of the manager part (Attachment1). As I said earlier, you’d move this part manually by positioning it based off of your Raycast normal, UpVector, or RightVector, depending on the direction the player is trying to move to. Then using Vector3:Cross to get a vector perpendicular to either UpVector or RightVector.

Remember, using these constraints does not require any other type of CFraming on the player’s character at all. You only need to position the manager part and should get smooth movement.

I think there may be a misunderstanding. I’m trying to make a wall climbing system similar to the one the solution shows in this post: Making a "Wall Climbing" System
Would the steps to replicating that system be identical to the ones you’ve given me? I’m unfamiliar without the terms “mantling” and “ledge scaling”, but I did just look them up.

–BUMP

Minimum characters limit