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

How can I set the rotation of a joint based on the CFrame of a part? [closed]

Asked by
AZDev 590 Moderation Voter
8 years ago

A little example of what I am trying to do

Let me go further in depth.

I'm creating an FPS. The gun and arms are welded to the head. Inside the gun there is a part called main. I want to rotate the joint so that the gun is rotated in such a way that the main is always pointing to the camera's lookVector. I'm hoping the screenshot I showed above will help explain this in more detail.

I thought that I would need to use toObjectSpace() but my attempt with this was a bit wacky.

I tried CF = Joint.C1:toObjectSpace(CFrame.new(Equipped.Main.CFrame.p, workspace.CurrentCamera.CFrame.lookVector))

My lack of understanding when it comes to some of the CFrame operators + the lack of documentation on ROBLOX's part when it comes to these operators is probably to blame here.

0
@BlueTaslem Mind checking this out? AZDev 590 — 8y
0
One, you never even explained what the joint is. Two, you can't "point at a lookVector". You can point at a position, which a vector is not. Do you mean to point at thiss: camera.CFrame.p + camera.Cframe.lookVector ? cabbler 1942 — 8y
0
Vector: A quantity having direction as well as magnitude, especially as determining the position of one point in space relative to another. AZDev 590 — 8y
0
@Cabbler, Next time you comment here (in a rather stern tone), please make sure you know what you're talking about. AZDev 590 — 8y

Locked by AZDev and shayner32

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?