|
| 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 |
|
|
|
| 02 Aug 2011 08:33 AM |
| The forum's very slow today |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2011 08:51 AM |
| Make a message that has the degrees. |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2011 09:05 AM |
| And how to find the degrees? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 02 Aug 2011 10:16 AM |
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ What on earth is that? |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2011 10:18 AM |
Advanced math.
:|
~ ROBERT00001 ~ ~(ಠωಠ)~ |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Aug 2011 10:27 AM |
Incorrect advanced math. -.- Hold on for a few more minutes... |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 02 Aug 2011 10:51 AM |
| Like AFF, what does that do? How to get the degrees? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 02 Aug 2011 12:41 PM |
| Hmmm, but I only want to get like one angle, not different for each. |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
| |
|