Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Making arms point relative to the position of the CurrentCamera?

Example: http://www.roblox.com/BATTLEFIELD-place?id=114127058

I want to make the arms point relative to where the CurrentCamera is looking. The reason why I want to calculate off of the Camera instead of the Mouse is because I plan for the mouse to be in the middle of the screen (First Person) when pulling this off. Now, I know this sort of requires two sets of arms, one for the screen (fake arms in the CurrentCamera), the other for the character (the real arms, so that the other players can see where the player is aiming). I already know how to set the fake arms in the CurrentCamera, but unfortunately, I don't know how to position the real arms. I would like to use the SetDesiredAngle method in the Motor6Ds to move the arms up and down, but I do not know the math to set the angle to point to the Camera, any help?

2 answers

For best effect, you weld the fake arms onto the real arms and make the fake arms non-transparent when the focus and the coordinate's delta magnitude is less than 1.

You then weld the real arms onto the head and make a new weld that replace the Neck Motor6D.

You move the head towards the camera something like

Weld.C0 = Weld.Part1.CFrame:inverse()*
CFrame.new(C0Numbers,C0Numbers+UnitVector)
*CFrame.Angles(rotation)
*CFrame.Angles(Offsetrotation)

2 comments

0

What is a delta magnitude, which C0 numbers, which unit vector, and which rotation?

0

By that I mean if the length of the vector between the two points are less than 0. C0 numbers is the number you would use as normal for C0. UnitVector is well... The direction you wanna look at. Rotation is how you wanna rotate it along with the offset rotation.

for FPS I prefer to use R6 real arms this is my local script:

plr = game.Players.LocalPlayer;
repeat wait() until plr.Character
char = plr.Character
m = plr:GetMouse()
game["Run Service"].RenderStepped:connect(function()
local c = game.Workspace.CurrentCamera

char.HumanoidRootPart["RootJoint"].C0 = CFrame.new(0,0,0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55,3.15,0)

	char.Humanoid.CameraOffset = (char.HumanoidRootPart.CFrame+Vector3.new(0,0,0)):pointToObjectSpace(char.Head.CFrame.p + Vector3.new(0,-1.46,0))

end)

This discussion is preserved as it was. New answers, comments, and votes are closed.