How to set just the Y orientation of a CFrame

Hello, i’m working on a hook that makes character go towards the mouse, it works pretty well and i can detect when he reaches the goal, but when it reaches it want to set the character orientation towards the wall the hook was in.

Before i was trying to set root part orientation Y to 0 or another number but it didn’t worked because what rotates the root part is a body gyro, and the body gyro doesn’t change the part orientation (this body gyro makes the character face to the mouse hit p), but i need to change just the Y orientation of the body gyro CFrame

So my question is: is there a way to set just the Y orientation of a CFrame?

1 Like

I may not understand, but you seem to be asking two dif. questions.

You can set the Gyro to look at the wall, instead of the mouse, by setting the second arg to the wall: Or if you know the direction of the wall you can also do it:

local CF =  CFrame.new(pos,  pos + dir)

–stuff CF into Gyro

This tilts the Z
local rotatedCFrame = CFrame.Angles(0,0,math.rad(bankangle))
bin:findFirstChild(“BodyGyro”).cframe = CF:ToWorldSpace(rotatedCFrame)

But I am bad at math, so you are gonna need more help…

1 Like

Yeah i think the post is confused, when i wrote i was sleepy

That’s the hook, when it reaches the red dot i need the character to be facing to the wall, but i don’t know how should i do this

Try moving the dot away from the surface your mouse is touching. Your character is clipping through the surface of the part as it’s moving to the point. As for changing certain axis, I’m pretty sure you can do what @BJCarpenter said and simply multiply the Angles component of CFrame by the tilt you want and zero the other components.

I would think that the above is all that you would need but it appears that u r already doing that and like cc says, maybe move the dot inside the wall and stop player from moving or something… But what do you want to do AFTER he is on the wall and facing dot…?

I already made it, when you reach the wall you get anchored and face the wall, but i can’t make the root part face the wall that’s why i made this post. I can’t do what you said because the root part will face to the dot but the root part position is the dot position so it’s like making a CFrame with 2 equal positions