Kratos232
|
  |
| Joined: 28 Oct 2011 |
| Total Posts: 229 |
|
|
| 08 Jan 2015 05:31 AM |
Hello. So, I'm making a FPS Game, but I don't know how to make the gun point at where the Mouse is. Since it's an FPS game, all it really needs to do is go up and down with the camera, it goes left and right when the Player turns.
So far, all it does is Weld the gun to his arm, but the Arm won't move up and down. |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2015 06:16 AM |
Hi. Here is how I do this.
Firstly, when in first person camera, your camera is centred inside the character's head. So, when you look up or down, you are rotating from the head. In order to make the arms move alongside the camera and point in the direction you are facing, you should (I know this sounds strange) change the shoulder joints so that they are between the head and each arm. You should probably just create a new weld for each arm. Then you need to use some basic trigonometry to work out the angle of elevation of your camera and then adjust the arm welds' c0/c1 values accordingly. |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2015 08:19 AM |
| The best way to do it i have found, is to simply NOT use the actual arms. Make them transparent, and make fake arms that are welded to a head that moves with the Camera. |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2015 10:13 AM |
"The best way to do it i have found, is to simply NOT use the actual arms. Make them transparent, and make fake arms that are welded to a head that moves with the Camera."
What's the difference between that and moving the shoulder joints? The shoulder joints is probably the shorter and easier method of the two, except that you need to disable the arm movement temporarily. |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2015 10:36 AM |
| The reason i do not use the shoulder joints is because if i want to be able to switch back to a normal stance, or gameplay, i can remove the gun and fake arms and not have to worry about messing up the animation script, or have to worry about resetting up the arms the right way. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 08 Jan 2015 11:34 AM |
Not tested but this should rotate the left arm towards the mouse.
function rotateArm(mouse,char) while wait() do local weld = char.Torso["Left Shoulder"] desired_p1 = CFrame.new( (weld.Part0.CFrame * CFrame.new(-1,.5,-.4)).p,mouse.Hit.p) * CFrame.Angles(math.pi/2,0,0) weld.C0,weld.C1 = CFrame.new(),desired_p1:inverse() * weld.Part0.CFrame end end
while wait() do local mouse = game.Players.LocalPlayer:GetMouse() rotateArm(mouse,game.Players.LocalPlayer.Character) end |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2016 03:47 AM |
| Sorry but I don't understand. (Kratos used to be part of my dev team till he left ROBLOX). |
|
|
| Report Abuse |
|
|