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

Make arms follow mouse (Like FPS)? [closed]

Asked by
Hero_ic 502 Moderation Voter
9 years ago

Is it possible to make the player arms visible and follow the mouse while in first person so it does not look like they are floating? (Like FPS)

I hope this question is not stupid.

1
Yes, this is possible. However, I do not have enough knowledge to give you a TRUSTable answer. (check out the Climbing game on ROBLOX) alphawolvess 1784 — 9y
1
That one is a freemodel and is done poorly... Hero_ic 502 — 9y
1
What would it mean to "follow the mouse" in first person? The mouse is always going to be in the same place -- in the middle of your screen. BlueTaslem 18071 — 9y
0
@BlueTaslem,I think he means the Arms stick out and follow the mouse. woodengop 1134 — 9y
View all comments (2 more)
1
I'm researching that for my upcoming game, Wilderness, but I can't get the arms to follow the mouse if there is a weld in the weapon. I'm seeking help with that, too. yumtaste 476 — 9y
0
What I mean by first person is like halo and such games. Not like the Climbing game. Hero_ic 502 — 9y

Locked by Spongocardo and dyler3

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

Why was this question closed?

1 answer

Log in to vote
8
Answered by 9 years ago
Edited 7 years ago

What I do is instead of making the arms follow the mouse, I weld my arms to the head of my character, offset the welds accordingly using the C1 property of the weld (this is so that the arms aren't inside of your head when you test the gun and it may need tweaking tons of times) and then use the following piece of code to find the angle that my mouse is looking up by, connecting the function to the RenderStepped event in the RunService, so your arms keep following the mouse on the Y axis.

game:GetService("RunService").RenderStepped:Connect(function() --Runs the function each time a frame is rendered.
    mouse.TargetFilter = workspace --This is important when setting the C0 at the bottom as it ignores everything in the workspace to give clean movement of the arms on the Y axis.
    player.Character.Torso.Neck.C1 = CFrame.new() --Sets the C1 to a blank CFrame so the head doesn't glitch.
    player.Character.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), 0, 0) --Moves the head up by 1.5 studs and then sets the angle of your character's neck looking up towards the mouse using inverse trigonometry (A grade maths) and unit vectors (so you only get the direction.)
end)

The math function that is used to calculate the angle of the mouse looking up is called math.asin. math.asin is a trigonometric function known as the arc sine, or inverse sine. Inverse trigonometry is A grade mathematical work and is quite confusing until you're taught it by your subject teacher, so I will not explain this fully as I am not a very good teacher with these sorts of things.

If you really want to know how to do the inverse sine, here is a link to a maths website which explains it quite well. I'm sorry that I can't explain inverse trigonometry to you personally as I am not a very good teacher.

I hope this helped you. If it did, please accept my answer.

0
I've tried welding the arms but the head gets welded to the arms and doesn't move, the head moves without the arm welds however like it should.. dragonkeeper467 453 — 9y
0
You need to have the Head as Part0 and the Arm at Part1, otherwise the head will be welded to the arm. Also, you need to make Part1 of the Shoulder Motor6Ds nil, otherwise it will not work. I would suggest storing each shoulder joint as a variable and making a variable for each Part1 of the shoulder so you can restore the shoulder Part1 when you unequip a tool. Spongocardo 1991 — 9y
Ad