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: Apply angles of one CFrame to another

Previous Thread :: Next Thread 
Brickagon is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
09 Jun 2015 07:42 PM
Try using the raw matrices
Report Abuse
Brickagon is not online. 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 is not online. 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 is not online. 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 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
09 Jun 2015 07:55 PM
Oh yeah
I'm such a derp
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