Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I CFrame-rotate something on only one axis?

Asked by 9 years ago

I'm currently trying to make a part go to wherever I click, which I 'm capable of doing, using CFrame.new(Mouse.Hit.p) - But, I want it to rotate with the mouse too. The mouse, suprisingly, has rotation CFrame too, as I discovered a while ago. I actually forget how I got it, but that's besides the point; I threw that part out when I couldn't figure out how to restrict it to one axis, IE, to turn it rather than to fully rotate and flip it too.

How would I go about getting the mouse's cframe, and restricting it so it only turns on one axis?

2 answers

Log in to vote
0
Answered by
Scriptecx 124
9 years ago
CFrame.new (Mouse.Hit.p, Vector3.new(Mouse.Hit.p.x, Part.Position.Y, Mouse.Hit.p.z))

Use this CFrame. The first Mouse.Hit.p gives it the position that it is going to go to when you click, and then the

Vector3.new(Mouse.Hit.p.x, Part.Position.Y, Mouse.Hit.p.z)

will rotate it to the position the the mouse it looking at on the y axis.

0
I don't know HOW it rotates it on the Y axis when you lock the Y axis to the part.position, and only change the X and Z axis. And for some reason this isn't working, it rotates them to a very weird angle - one axis turns it sideways, the other flips it on its side, and the Y axis jut turns it diagonally. (Tried them all separately.. ) Maxwell_Edison 105 — 9y
0
I'm using Template:SetPrimaryPartCFrame(CFrame.new(Mouse.Hit.p + Vector3.new(0,0.5,0), Vector3.new(Mouse.Hit.p.x, Template.PrimaryPart.Position.y, Mouse.Hit.p.z))) - what am I doing wrong? Maxwell_Edison 105 — 9y
0
No matter how I combine them, they seem to not even orient based on the mouse's cframe, just a static, weird angle Maxwell_Edison 105 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Found alternate method myself.

Answer this question