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
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 28 Aug 2015 09:33 AM |
| EulerAnglesXYZ() multiply it in with rotation |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 28 Aug 2015 11:06 AM |
1/6 of a full revolution 60 degrees |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 01 Nov 2011 |
| Total Posts: 1312 |
|
|
| 28 Aug 2015 03:15 PM |
| Someone should just make a plugin for this |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|