Any way to make a certain cframe angle point towards me?

yo, i’m making a c4 system and i’m wondering if there’s any way to make a certain angle in a cframe point towards me, i know i can make a whole cframe point towards me, but i dont know if i can do it with one angle.

TLDR; I want the c4 in the video to point at me, with the Y angle.

The way that I suggest to get around that is to make it point towards your character’s current position (using CFrame.lookAt(), and just set the lookAt’s Y position to the C4’s Y position.

1 Like

You can use CFrame.lookAt(), it takes in an origin position, a position to look at and an UpVector

--Yaws a part (rotates it on its Y axis) to face towards a point in world-space.
function pointYawTowardsPoint(part, point)
    local pointRelative = part.CFrame:PointToObjectSpace(point)
    local yawAngleRelative = math.atan2(pointRelative.Z, pointRelative.X)
    part.CFrame *= CFrame.new(0, yawAngleRelative, 0)
end

I might have flipped the coordinates or the signs of the coordinates in the atan2 call. If the model just spazzes out or has unpredictable rotation, try flipping the signs or reversing the order. Oh, and make sure the Y axis of the C4 model is actually the one that’s supposed to point “out from the surface”

2 Likes

tried the code and it didn’t seem to work, i can show you what i’m working with.

					part.CFrame = CFrame.new(pos,pos + normal)*CFrame.Angles(math.rad(180),math.rad(90),math.rad(90))
					pointYawTowardsPoint(part,script.Parent.Head.Position)
					cf = part.CFrame*CFrame.new(0,0.1,0)

sorry for the indents.

well, that would ruin the surface normal, i think. I marked it as a soloution because it worked for a second untill i realised it just ruins the surface normal

1 Like

Hey! i messed around with the code you sent, (huge thanks btw) and i figured you didn’t really understand what i meant.
But, on the 2nd last line i changed the CFrame.new into CFrame.Angles and that worked, thanks alot! <3

1 Like