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
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Axis of rotation

Previous Thread :: Next Thread 
Jeysea is not online. Jeysea
Joined: 13 Apr 2015
Total Posts: 268
28 Aug 2015 09:31 AM
How can you change the axis of rotation on a part? By default, the axis of rotation is at the center of a part. I'm trying to rotate an arm, but I want it to rotate at the shoulder (top of the arm) instead of the center of the arm. Anyone know how?
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
28 Aug 2015 09:33 AM
EulerAnglesXYZ() multiply it in with rotation
Report Abuse
Jeysea is not online. Jeysea
Joined: 13 Apr 2015
Total Posts: 268
28 Aug 2015 09:35 AM
Can you give an example? I don't know how to do this at all.
Report Abuse
Jeysea is not online. Jeysea
Joined: 13 Apr 2015
Total Posts: 268
28 Aug 2015 09:45 AM
Please, I really would like to know how to do this so my FPS doesn't look strange when bullets fly from the top of the gun.
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
28 Aug 2015 10:18 AM
It's not too hard. You need to "offset" the center of rotation.

Here's an example of swinging a part from its right side.

local P = workspace.Part
local RightDirectionFrame = P.CFrame + P.CFrame:vectorToWorldSpace(Vector3.new(1,0,0) + P.Size.X/2)
P.CFrame = P.CFrame * (RightDirectionFrame * CFrame.Angles(0,math.pi/3,0) * CFrame.new(P.Size.X/-2,0,0))
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
28 Aug 2015 11:03 AM
nox, u should make a Module for this kind of CFrame stuff :D :P
btw, may I ask, what was the 'math.pi / 3' for?

"My Life is going Good... but..."
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
28 Aug 2015 11:06 AM
1/6 of a full revolution
60 degrees
Report Abuse
AkaLua is not online. AkaLua
Joined: 27 Jul 2012
Total Posts: 526
28 Aug 2015 11:17 AM
Didn't know offset was that simple XD.
Used to think Sin and Cos was the only way to do that stuff.
Report Abuse
Jeysea is not online. Jeysea
Joined: 13 Apr 2015
Total Posts: 268
28 Aug 2015 01:30 PM
It doesn't seem to work right with joints.
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
28 Aug 2015 02:24 PM
"It doesn't seem to work right with joints."

That's important information and I'm not sure why you never said that at first. Joints work in object-space coordinates - not world-space (as parts do). It's totally different.
Report Abuse
Exzeption is not online. Exzeption
Joined: 01 Nov 2011
Total Posts: 1312
28 Aug 2015 03:15 PM
Someone should just make a plugin for this
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
28 Aug 2015 03:18 PM
You just offset the CFrame of the part (Literally moving the center to the offset):


function offsetRotation(cfn1, offset, rotation)
return cfn1 * offset * rotation * offset:inverse()
end

workspace.Part.CFrame = offsetRotation(workspace.Part.CFrame, CFrame.new(0, .5, 0), CFrame.Angles(math.pi/4, 0, 0))
Report Abuse
XYuy is not online. XYuy
Joined: 24 Dec 2010
Total Posts: 5628
28 Aug 2015 04:02 PM
eulerAnglesXYZ()


how many threads can a threadchuck chuck if a threadchuck can chuck threads
Report Abuse
Jeysea is not online. Jeysea
Joined: 13 Apr 2015
Total Posts: 268
29 Aug 2015 06:35 AM
Okay, I still don't know how and I would really appreciate an example that used variable names I could understand. :D
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
29 Aug 2015 07:15 AM
While this is not exactly what you asked for, it should be a bit more explanatory.
Also, if you are really trying to rotate an arm, then this IS what you want.
http://wiki.roblox.com/index.php?title=Joint#Programmatic_Creation
Report Abuse
Jeysea is not online. Jeysea
Joined: 13 Apr 2015
Total Posts: 268
29 Aug 2015 07:38 AM
I'm on that wiki page already, but I when I change the axis of rotation as they do in the rotating joint section, it just makes the part change location and rotate about it's position again. :s
Report Abuse
Jeysea is not online. Jeysea
Joined: 13 Apr 2015
Total Posts: 268
29 Aug 2015 09:25 AM
I can rotate the arm to where I want it, but now I don't know how to make it follow the mouse. Is it possible to find the angle of rotation on the camera in first person and apply that same rotation to the arm?
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
30 Aug 2015 08:27 AM
local y = math.asin(cam.CoordinateFrame.lookVector.Y)
assuming 'cam' is already defined

"My Life is going Good... but..."
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