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: CFrame -> Orientation

Previous Thread :: Next Thread 
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
23 May 2017 02:53 PM
I want to convert a specific axis of a CFrame object to degrees. After looking over the documentation, I'm lost for which method I should use to accomplish this.
I've experimented with :toAxisAngle() and :EulerAnglesXYZ(), but I'm uncertain of what they actually return. Could someone either explain them more in-depth or tell me other methods to accomplish my goal?

For example what I want to do.

local c = CFrame.new(pos1, pos2);

print(c:WhatMethodShouldIUse().Y) -- -180 <= Angle of the Y-axis <= 180
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 02:59 PM
they return the rotational components x,y,z in radians local x,y,z = c:toEulerAnglesXYZ() however u probably should not be using orientation, and instead just use cframe for accuracy object.CFrame = ##################### - pos1 + object.CFrame.p --gets rid of the position and moves it back
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 03:00 PM
they return the rotational components x,y,z in radians

local x,y,z = c:toEulerAnglesXYZ()

however u probably should not be using orientation, and instead just use cframe for accuracy

object.CFrame = CFrame.new(position1, position2) - position1 + object.CFrame.p --gets rid of the position and moves it back
Report Abuse
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
23 May 2017 03:04 PM
I'm actually intending to convert roblox's rotation to 0 -> 360 to rotate a gui.
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 03:06 PM
on which axis?
if u want like a gps then do

math.deg( math.atan2( lookVector.Z, lookVector.X ) )
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 03:06 PM
since it forms a right triangle it finds the angle between those 2 legs in case u were wondering "WHY"
Report Abuse
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
23 May 2017 03:08 PM
Hehe, you saw through my plan, I wasn't sure on how arch tangent work so I was using that hacky method. Thanks for the help by the way.
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
23 May 2017 03:10 PM
goo.gl/m8lQxT

explains why

and the reason why X and Z is because that is rotation based on the Y axis
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