I want to make align a part with a wall when I hit the ray cast and Idk how here’s what a script that just makes the person look at the wall and be on the wall but I don’t know how to orientation the character if the player goes up and down.
Sorry but, any more information on exactly what you want? Like a contextual use-case scenario like for example wall climbing or a wall stick mechanism.
Yep, I’m confused on what orientation means in this scenario as well, forgot to ask about that thanks.
A gif or video showing the problem will be really helpful as well.
However for the code given I recommend splitting it up into seperate variables and using the new CFrame.lookAt constructor
local currentPlayerPos = HRP.CFrame.Position
local surfaceNormal = Normal
local lookAt = currentPlayerPos-surfaceNormal
HRP.CFrame = CFrame.lookAt(currentPlayerPos, lookAt)
bodygyro.CFrame = CFrame.new(currentPlayerPos, lookAt)
this should make the player look at a point towards the wall from the player’s position.
Yeah, I recommend using imgur since it embeds automatically onto Discourse unlike streamable. I did it for you lol:
Anyways the problem with the original code is that the CFrame only orientates in the XZ plane. As seen in the vector 3 construction for the CFrame.new() parameter for the look at the position below:
Try using this below which should make the player look towards the wall via vector maths with the surface normal and the player position which I gave above a well.