generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Welding an arm to the TargetPoint of a Tool

Previous Thread :: Next Thread 
DemonicRegalia is not online. DemonicRegalia
Joined: 25 Jun 2010
Total Posts: 3383
28 Mar 2013 10:32 PM
Scripting Help didn't do it's job, so I'm here. Say the TargetPoint is (30, 5, 30), how would I go about welding the right arm to point at the target?
Report Abuse
kirkyturky12 is not online. kirkyturky12
Joined: 30 Apr 2010
Total Posts: 1915
28 Mar 2013 10:41 PM
I can't tell you my secrets.

Oh, and, reported for spam.
Report Abuse
Causticity is not online. Causticity
Joined: 11 Jun 2012
Total Posts: 530
28 Mar 2013 11:20 PM
Well what I do is weld something in the head and then weld whatever you need, such as a gun or a right arm to the head and move the head's weld around. Use a cool formula like so:

local lv = mouse.Hit:vectorToWorldSpace(Vector3.new(0,0,-1))
neck.C1 = CFrame.new(0,1.5,0) *CFrame.Angles(math.atan2(lv.y,pythag(camera.CoordinateFrame.lookVector.x, camera.CoordinateFrame.lookVector.z))+.1,0,0)

'pythag' just being a function to return math.sqrt(a^2 + b^2)
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
28 Mar 2013 11:35 PM
It's really simple so long as you understand that joints just use object-spaces and not world coordinates.

local targPoint = Vector3.new(30,50,0)
local joint = ? -- The weld or whatnot.
-- After setting the parts for the joint, you can set the C1 (or if you're using the default character joints, just set joint to the Right Shoulder)
joint.C1 = CFrame.new(joint.Part1.Position, targPoint):toObjectSpace(joint1.Part0.CFrame
Report Abuse
kirkyturky12 is not online. kirkyturky12
Joined: 30 Apr 2010
Total Posts: 1915
28 Mar 2013 11:39 PM
@Causticity
Olololol. That's too complicated. Here's what I do:

local Pos = Torso.CFrame:pointToObjectSpace(Mouse.Hit.p)
ArmWeld.Part0 = Torso
ArmWeld.Part1 = RightArm
ArmWeld.C1 = CFrame.new(0,0.5,0, 1,0,0, 0,0,1, 0,-1,0)
ArmWeld.C0 = CFrame.new(Vector3.new(1.5,0.5,0),Pos)

Oh, and, reported for spam.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image