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: How do I get the orientation of a part?

Previous Thread :: Next Thread 
hamburger621 is not online. hamburger621
Joined: 20 Apr 2013
Total Posts: 845
09 Oct 2017 02:31 PM
I know when you get the Part.Position, it saves the position as a vector3, but How would I get the orientation, would it be just Part.Orientation?
Report Abuse
hamburger621 is not online. hamburger621
Joined: 20 Apr 2013
Total Posts: 845
09 Oct 2017 02:52 PM
b
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
09 Oct 2017 02:52 PM
yes
Report Abuse
hamburger621 is not online. hamburger621
Joined: 20 Apr 2013
Total Posts: 845
09 Oct 2017 03:18 PM
And then how would I add that orientation to the vector3? i'm pretty sure I have to convert the orientation to radians, and multiply the position by the radians, but how would I convert the orientation to radians?
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
09 Oct 2017 03:21 PM
orientation is a Vector3
Report Abuse
hamburger621 is not online. hamburger621
Joined: 20 Apr 2013
Total Posts: 845
09 Oct 2017 03:28 PM
But how would I move a model using its position and orientation? so that it factors in both when moving it
Report Abuse
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
09 Oct 2017 03:31 PM
If you're using vector3's then:

part.Position = newPosition
part.Orientation = newOrientation






Report Abuse
hamburger621 is not online. hamburger621
Joined: 20 Apr 2013
Total Posts: 845
09 Oct 2017 03:42 PM
How would I apply that to a primary part, as to rotate the entire model?
Report Abuse
hamburger621 is not online. hamburger621
Joined: 20 Apr 2013
Total Posts: 845
09 Oct 2017 03:58 PM
b
Report Abuse
RonDeRainyDays is not online. RonDeRainyDays
Joined: 25 Apr 2014
Total Posts: 377
09 Oct 2017 04:02 PM
the only functions for moving a model based on the primary part are MoveTo, which is Vector3, but just position, and SetPrimaryPartCFrame, which is CFrame, but position and rotation. Instead of using orientation, it might be easier to just use cframe. Although i'm sure there is a formula somewhere for converting a position and orientation into a cframe
Report Abuse
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
09 Oct 2017 04:06 PM
You'll have to use CFrames.

model:SetPrimaryPartCFrame(CFrame.new(0,0,0) * CFrame.Angles(0,math.rad(90),0))

CFrame.Angles takes rotations in radians, so if you're more familiar with degrees you'll need to use math.rad(xDeg)

Report Abuse
hamburger621 is not online. hamburger621
Joined: 20 Apr 2013
Total Posts: 845
09 Oct 2017 04:19 PM
I typed this: game.Workspace.Tycoons.Tycoon1.Triplane.Model.Plane:SetPrimaryPartCFrame(CFrame.new(Hit) * CFrame.Angles(Radians)) but returned: ############ - Workspace.Tycoons.Tycoon1.Triplane.Model.Regenerate:70: bad argument #3 to 'Angles' (number expected, got no value) Hit is the position as a variable, and Radians is the orientation calculated in radians, stored as a variable
Report Abuse
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
09 Oct 2017 04:26 PM
How are you setting the radians variable? I'm fairly certain that CFrame.Angles only takes x,y,z radians as individual values and not a CFrame or vector3

Report Abuse
hamburger621 is not online. hamburger621
Joined: 20 Apr 2013
Total Posts: 845
09 Oct 2017 04:27 PM
it is in the format of Vector3: X,Y,Z
They are converted to Radians just using the formula: Degrees * PI / 180
Report Abuse
hamburger621 is not online. hamburger621
Joined: 20 Apr 2013
Total Posts: 845
09 Oct 2017 04:32 PM
Ok I see what you mean now, but I'm confused again.

If I have the Orientation saved in a variable as "0, -90, 0" how would I then pull just the -90 out? That way I could get CFrame.Angles to work properly
Report Abuse
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
09 Oct 2017 08:40 PM
If I were you, I would save the rotation as a Vector3, or perhaps 3 individual values.

Ex: local rotVec3 = Vector3.new(0,-90,0)
local newRotation = CFrame.Angles(rotVec3.X, rotVec3.Y, rotVec3.Z)

or

local rotX, rotY, rotZ = 0, -90, 0
local newRotation = CFrame.Angles(rotX, rotY, rotZ)

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