How do I CFrame a part on a slope to face the camera while remaining flat on the slope?
Raycast is a point on the slope.
local X,Y,Z = self.CurrentCamera.CFrame:ToOrientation()
Part.CFrame = CFrame.lookAlong(Raycast.Position, Raycast.Normal) * CFrame.fromOrientation(0,Y,0)
This comes pretty close, but it’s not quite right.
Use Cframe.loookvector,Unit
check documentation on this if you don’t know what it is.
Can you give an example please?
And what do you mean LookVector.Unit? LookVectors are already unit vectors, no?
just use lookvector then. Can’t you just use that?
Can you please elaborate on this a bit?
edit: I’ve tested it more thoroughly and I think I see what you mean. Give me a bit to fix it up!
I just realized that the slope part’s orientation is a factor too. I didn’t account for that.
Are you able to provide further elaboration on what you are actually trying to do, and optionally provide a repo file with what you currently have?
I am raycasting a “preview” of a deployable item so the player can see where it will be placed. The preview should always face the player, but also needs to be flat on a slope so it isn’t floating/clipping into the slope. The deployable item is a small wall/shield.