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: Rotation degree

Previous Thread :: Next Thread 
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 08:19 AM
How to find how many degrees a brick will have to rotate in order to face a certain position?
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 08:33 AM
The forum's very slow today
Report Abuse
IWantToBeAFamousGuy is not online. IWantToBeAFamousGuy
Joined: 11 Jun 2011
Total Posts: 42
02 Aug 2011 08:51 AM
Make a message that has the degrees.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 09:05 AM
And how to find the degrees?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
02 Aug 2011 09:42 AM
There's two ways to do this.


CFrame.new(Position, PositionToLookAt)


Will post the other way in a minute or two.
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
02 Aug 2011 09:46 AM
x1, y1, z1 = cframe1:toEulerAnglesXYZ()
x2, y2, z2 = cframe2:toEulerAnglesXYZ()
print(x2-x1,y2-y1,z2-z1)

that should show the degrees that cframe1 needs to rotate on each axis to get to cframe2's rotation

~Sorcus
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 09:54 AM
Awesme :)
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
02 Aug 2011 10:12 AM
@CP4

Not exactly.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 10:14 AM
AFF, but what you did is make it rotate towards that. I don't want that. I want to find how many degrees it will have to rotate.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
02 Aug 2011 10:15 AM
Here's the other way:



function getEulerAnglesXYZ(Part, PartToLookAt)
local dif = (Part.Position - PartToLookAt.Position)
local x = -math.acos( dif.z/(dif.y^2 + dif.z^2)^0.5 )
local y = math.acos( dif.z/(dif.x^2 + dif.z^2)^0.5 )
local z = math.acos( dif.x/(dif.y^2 + dif.x^2)^0.5 )
return x, y, z
end

local x, y, z = getEulerAnglesXYZ(workspace.Looker, workspace.Part)
workspace.Looker.CFrame = workspace.Looker.CFrame * CFrame.Angles( x, y, z )
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 10:16 AM
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
What on earth is that?
Report Abuse
Robert00001 is not online. Robert00001
Joined: 15 May 2010
Total Posts: 7965
02 Aug 2011 10:18 AM
Advanced math.

:|

~ ROBERT00001 ~
~(ಠωಠ)~
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 10:19 AM
Like what's it do?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
02 Aug 2011 10:27 AM
Incorrect advanced math. -.-
Hold on for a few more minutes...
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 10:33 AM
Lawl
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
02 Aug 2011 10:44 AM
Just use this...
It's much faster than any user-generated code anyway.



local x, y, z = CFrame.new(workspace.Looker.Position, workspace.Part.Position):toEulerAnglesXYZ()
workspace.Looker.CFrame = CFrame.new(workspace.Looker.Position) * CFrame.Angles( x, y, z )
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
02 Aug 2011 10:48 AM
@Agent: Correct me if I'm wrong, but wouldn't that basically be the same as:

workspace.Looker.CFrame = CFrame.new(workspace.Looker.Position, workspace.Part.Position)

?

~Sorcus
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 10:51 AM
Like AFF, what does that do? How to get the degrees?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
02 Aug 2011 10:55 AM
"@Agent: Correct me if I'm wrong, but wouldn't that basically be the same as:

workspace.Looker.CFrame = CFrame.new(workspace.Looker.Position, workspace.Part.Position)

?"


Yes, but the whole point of the thread was to get the ANGLES. I got the angles with that script, then set the CFrame to show that the angles are accurate.


@cm22

The first line (local x, y, z = .....) gets your angles. The variables x, y, z represent the angles on each axis.
Report Abuse
TheNewFissy is not online. TheNewFissy
Joined: 03 Jan 2011
Total Posts: 1301
02 Aug 2011 10:56 AM
Code [[

local x, y, z = CFrame.new(workspace.Looker.Position, workspace.Part.Position):toEulerAnglesXYZ()
workspace.Looker.CFrame = CFrame.new(workspace.Looker.Position) * CFrame.Angles( x, y, z )

]] Code

X,Y,Z variables are the rotation. workspace.Looker is turned in the same rotation as the rotation between workspace.Looker's position and workspace.Part's position.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 12:38 PM
Oh my gosh. I want a simple thing. Look at this

l /
I want to find out how many degrees the second line will have to move to face the first line.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 12:41 PM
Hmmm, but I only want to get like one angle, not different for each.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 12:52 PM
bump
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
02 Aug 2011 01:48 PM
function getAngleToPoint(brick, position)
return math.acos( brick.CFrame.lookVector:Dot(position) / position.magnitude )
end

print(
math.deg( getAngleToPoint( workspace.Part, Vector3.new(10,10,10) ) )
)


The angle will ALWAYS be between 0 and 180.
0 <= x <= 180
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
02 Aug 2011 04:02 PM
@AFF
Thanks!
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