So as you guys know doing CFrame.new(pos,look) will create a CFrame at pos oriented to look.

I was wondering how you could make a CFrame that is offset from another point that can only rotate around said point but still have it’s lookVector face the look position.

If I do,

while wait() do
	part1.CFrame = CFrame.new((part0.CFrame * CFrame.new(0,part0.Size.Y/2,0)).p,target.CFrame.p)
end

I get the problem which is the part is centered on the offset point(which happens to be the top of another part). That looks like this However, I can do

while wait() do
	part1.CFrame = CFrame.new((part0.CFrame * CFrame.new(0,part0.Size.Y/2,0)).p,target.CFrame.p) * CFrame.new(0,part1.Size.Y/2,0)
end

This results in something that looks okay

The problem is because I moved it up the angle is actually off by a little bit

It’s very little but I was wondering if there is a better method for getting an accurate CFrame?

4 comments

0

While this is not to help your actual problem, you should not be calling wait() in the conditional portion of the while loop.

0

yea i know this is just for simple testing of the CFraming element, but thanks for the reminder.

0

i dont get what you mean by the angle is off by a little bit

0

So I make the CFrame so that at the position it is looking towards the other point. But I need to move it up so that it appears to be on top, and this makes the angle off because now it pointing above the target rather than on it.