Brickagon
|
  |
| Joined: 01 Jun 2015 |
| Total Posts: 366 |
|
|
| 09 Jun 2015 07:30 PM |
I have a brick with slight rotation.
I want to add the CurrentCamera's rotation to it, so that from the perspective of the camera, this brick is always facing the same way.
How to do? |
|
|
| Report Abuse |
|
|
Brickagon
|
  |
| Joined: 01 Jun 2015 |
| Total Posts: 366 |
|
|
| 09 Jun 2015 07:38 PM |
Can I just use
local x,y,z = Camera.CoordinateFrame:toEulerAnglesXYZ()
and then multiply the brick's CFrame by CFrame.Angles(x, y, z) to accomplish this? |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 09 Jun 2015 07:40 PM |
One of the ten Commandments:
Thou shalt not use Euler Angles |
|
|
| Report Abuse |
|
|
Brickagon
|
  |
| Joined: 01 Jun 2015 |
| Total Posts: 366 |
|
|
| 09 Jun 2015 07:41 PM |
I know there's always a better way than using Euler Angles (okay, not always, but almost). But I don't know what else to do.
I really should sit down and take the time to learn CFrames. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 09 Jun 2015 07:42 PM |
| Try using the raw matrices |
|
|
| Report Abuse |
|
|
Brickagon
|
  |
| Joined: 01 Jun 2015 |
| Total Posts: 366 |
|
|
| 09 Jun 2015 07:47 PM |
pls tell me its simple
if I take the components and add the matrices together, it will do what i want? right?? :D ! |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 09 Jun 2015 07:48 PM |
| I suppose so. There's an easier solution that I forgot about, though |
|
|
| Report Abuse |
|
|
Brickagon
|
  |
| Joined: 01 Jun 2015 |
| Total Posts: 366 |
|
|
| 09 Jun 2015 07:50 PM |
Okay, easier solution.
local Camera = workspace.CurrentCamera local Rot = (Camera.CoordinateFrame - Camera.CoordinateFrame.p)
'Rot' now contains a CFrame which has X, Y, Z set to 0, but preserved the angles.
Now can't I just do this to apply it and merge them?
Brick.CFrame = Brick.CFrame * Rot |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
| |
|