|
| 08 Sep 2012 09:56 PM |
| Im moving multiple parts that are already CFramed, and they lose their rotation when I try to move them with CFrame. How do I both move them, yet have them keep their CFrame values? |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2012 09:58 PM |
you mean simple translations? you can do this:
CFrame.new() + Vector3.new()
¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests! |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2012 10:02 PM |
I have CFramed parts that I need to move with more CFrame. I used CmdUtl to CFrame these parts, and a script to move them, but they lose their angular CFrame.
p.CFrame = p.CFrame * CFrame.Angles(r1, r2, r3) --ROTATION
p.CFrame = CFrame.new(x, y, z) --MOVING |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 08 Sep 2012 10:07 PM |
| If you want to preserve angles without knowing what they are, you have to do a translation, you can't just plop them exactly where you want them to go. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2012 10:11 PM |
p.CFrame = CFrame.new(x, y, z) * p.CFrame:toEulerAnglesXYZ()
¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests! |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2012 10:11 PM |
| You don't understand...This is an elevator....A CFramed elevator that moves with CFrame...I want to know how to preserve the CFrame of the parts, but move them to different floors with CFrame too. |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 08 Sep 2012 10:13 PM |
p.CFrame = p.CFrame + Vector3.new(x, y, z)
That's all you have to do to preserve the angles. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2012 10:16 PM |
| Thank you, doombringer42. Your solution of toEulerAnglesXYZ() works PERFECTLY! |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2012 10:17 PM |
BAM!
¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests! |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 08 Sep 2012 10:24 PM |
| basePart.CFrame = basePart.CFrame * CFrame.new(0,0,0) |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2012 10:30 PM |
CFrame multiplication is complicated... involves nonsensical matrix math and other headaches. i don't think that does what he wants, though!
¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests! |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 08 Sep 2012 10:31 PM |
| Well, unless I misinterpreted his problem, then that's what it sounds like he wants. |
|
|
| Report Abuse |
|
|
|
| 08 Sep 2012 10:32 PM |
he wants to set an object's CFrame while preserving the former CFrame's angles.
what you're doing is transforming the CFrame from object to world coordinates, which is different to my understanding :o
¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests! |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
| |
|
|
| 09 Sep 2012 03:16 AM |
I am interseted in this as well. The CFrame and Euler angle wiki articles could be written a lot better to explain all this stuff. Where's an explanation a kid can understand of the various CFrame methods, for example? If you don't understand it already, it's like poking around a dark room with a stick trying to find where you are, rather than being able to turn on the lights.
By the way, I tried p.CFrame = CFrame.new(x, y, z) * p.CFrame:toEulerAnglesXYZ()
but I get the following error:
Workspace.Part.Script:5: bad argument #2 to '?' (Vector3 expected, got number)
What did I do wrong?
In any case, after many hours of fiddling around, I found something that works, but there has to be a better way. Here's what I found to work:
local originalRotation = p.CFrame - p.Position p.CFrame = CFrame.new(x,y,z) * originalRotation
|
|
|
| Report Abuse |
|
|