|
| 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 |
|
|
| |
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
| |
|
|
| 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
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
| |
|
|
| 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 |
|
|
|
| 09 Oct 2017 03:31 PM |
If you're using vector3's then:
part.Position = newPosition part.Orientation = newOrientation
|
|
|
| Report Abuse |
|
|
|
| 09 Oct 2017 03:42 PM |
| How would I apply that to a primary part, as to rotate the entire model? |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|