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

Finding distance after Rotation?

Asked by
Edenojack 171
8 years ago

I have 3 parts in play. Part 1, Main a part of a gun model with its CFrame manipulated in every Frame. Part 2, the Camera. Part 3, a part of the gun model with the exact X,Y coords of the ADS I want.

I want the X and Y CFrames of Part 2 and Part 3 to be the same, but I can only manipulate the CFrame of Part 1.

My problem is that I rotate Part1 around a Z axis, changing how much I have to move Part 1, to achieve X and Y CFrames being the same. I've worked out the distance of Part1->Part3 and Part2->Part1, but I can't seem to figure out a method of applying this.

Here is my code:

GModel.PrimaryPart.CFrame = Cam.CoordinateFrame*KeyPositions.Main*CFrame.Angles(0,0,-math.rad(MoveVec.Z*35))*

KeyPositions.Main and MoveVec.Z both change dynamically.

is there any equations I should be looking at?

Answer this question