rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 15 Jun 2012 10:10 PM |
I am currently trying to make it so that your arms will move with the mouse while holding a gun. The left hand works perfectly and the dot that I put out there to display where I want the gun is in the proper place however, the right shoulder gets stuck sideways inside of the left arm and appears to be moving in a random fashion. Can anyone spot my mistake?
local handle_pos=torso.CFrame*(CFrame.new(0,CFrame.new(torso.CFrame.p,mouse.Hit.p).lookVector.y,0))*CFrame.new(0,0,-2); pcall(function() obj:Destroy(); end); obj=dot(handle_pos); --left arm local left_shoulder=torso.CFrame*CFrame.new(-1,1,0); local desired_p1L=CFrame.new((left_shoulder.p+handle_pos.p)/2,handle_pos.p)*CFrame.Angles(math.pi/2,0,0); weldL.C0=CFrame.new(); weldL.C1=desired_p1L:inverse()*weldL.Part0.CFrame; --right arm local right_shoulder=torso.CFrame*CFrame.new(1,1,0); local desired_p1R=CFrame.new((right_shoulder.p+handle_pos.p)/2,handle_pos.p)*CFrame.Angles(math.pi/2,0,0); weldR.C0=CFrame.new(); weldR.C1=desired_p1R:inverse()*weldR.Part0.CFrame;
|
|
|
| Report Abuse |
|
|
|
| 15 Jun 2012 10:55 PM |
| First of all, Lua doesn't need those semi-colons. It recognizes white-space |
|
|
| Report Abuse |
|
|
| |
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
|
| 15 Jun 2012 11:29 PM |
| Yes, in very very few scenarios does it need it. |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 16 Jun 2012 12:07 AM |
And I use them. It's a style choice, who cares?
Anyone see the problem with my right arm? |
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 16 Jun 2012 12:32 AM |
| I tested your script (Using the Right and Left Shoulders Motor6D's stored in the torso, and I didn't get the error you described, both arms seem to be working perfectly on the Y axis which I guess is pretty much what you want. |
|
|
| Report Abuse |
|
|
Spectrumw
|
  |
| Joined: 04 Aug 2009 |
| Total Posts: 13510 |
|
|
| 16 Jun 2012 01:55 AM |
| Nevermind, you get the error because of the Animate script inside the character, which sets the DesiredAngle of the arm to 1.5 thus messing the script, you can easely fix this by editing and replacing the Animate script with a 'passive' animation, that lets the DesiredAngle in 0. At least that's how I managed to fix it. |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 16 Jun 2012 08:23 AM |
@spec Thanks, I didn't think it had to do with my math but wasn't sure. |
|
|
| Report Abuse |
|
|