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 » Scripting Helpers
Home Search
 

Re: CFrame movement, keeping angles?

Previous Thread :: Next Thread 
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
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
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
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
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
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 is not online. 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
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
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
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
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 is not online. 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
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
08 Sep 2012 10:16 PM
Thank you, doombringer42. Your solution of toEulerAnglesXYZ() works PERFECTLY!
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
08 Sep 2012 10:17 PM
BAM!

¬ Scripter Tier-2, LuaLearners Elite ♣ scripting teacher/freelance worker ♣ send me trade requests!
Report Abuse
nate890 is not online. 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
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
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 is not online. 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
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
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 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
08 Sep 2012 10:36 PM
Oh well.
Report Abuse
TechnicBeam is not online. TechnicBeam
Joined: 06 Feb 2011
Total Posts: 8
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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