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

Make arms follow mouse (Like FPS)?

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.

6 comments

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)

1

That one is a freemodel and is done poorly...

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.

0

@BlueTaslem,I think he means the Arms stick out and follow the mouse.

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.

0

What I mean by first person is like halo and such games. Not like the Climbing game.

1 answer

✓ Accepted answer

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.

2 comments

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..

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.

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