|
| 22 Mar 2017 08:45 AM |
I don't remember it ever doing this? Simple enough. I have a model with 5 parts, moving its position using SetPrimaryPartCframe moves the model correctly but also rotates the Primary Part so its rotation is (0,0,0) when its rotation pre-cframe is (-90, 90, 0)
Any way to stop this? |
|
|
| Report Abuse |
|
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 22 Mar 2017 09:54 AM |
instead of doing
Model:SetPrimaryPartCFrame = CFrame.new()
do
Model:SetPrimaryPartCFrame = Model:GetPrimaryPartCFrame() * CFrame.new()
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|
RogueMage
|
  |
| Joined: 28 Jan 2012 |
| Total Posts: 1235 |
|
|
| 22 Mar 2017 10:12 AM |
^
CFrame.new() without multiplying by any other CFrames resets it to its "original" Frame (Sort of) with a CFrame of (0, 0, 0)
Multiplying it by its own CFrame "adds on" to that CFrame in a way and gets the desired effect |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2017 12:17 PM |
What if I want to position it at the same time?
I'm doing this: SpawnSlot:SetPrimaryPartCFrame(CFrame.new(0, 50, 0) * CFrame.new()) Spawnslot is the model with 5 parts. It moves to 0,50,0 but does not rotate. |
|
|
| Report Abuse |
|
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 24 Mar 2017 01:12 PM |
You didn't rotate it in the code.
CFrame.Angles(math.rad(x),math.rad(y),math.rad(z))
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2017 02:50 PM |
Sorry, I'm really bad at this. I don't know how I would combine that with the translation, since using two separate :SetPrimaryPartCFrame's can only result in one of the results.
This the rotation you gave me, which works perfectly, thanks.
local ppR = SpawnSlot.PrimaryPart.Rotation SpawnSlot:SetPrimaryPartCFrame( CFrame.Angles(math.rad(ppR.X),math.rad(ppR.Y),math.rad(ppR.Z))) |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2017 02:53 PM |
'Model:SetPrimaryPartCFrame = Model:GetPrimaryPartCFrame() * CFrame.new()' completely wrong you do not understand what data type SetPrimaryPartCFrame is |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2017 03:12 PM |
Took a break, came back, got it.
For future reference if anybody else has this problem:
local ppR = Model.PrimaryPart.Rotation Model:SetPrimaryPartCFrame(CFrame.new(0, 50, 0) * CFrame.Angles(math.rad(ppR.X),math.rad(ppR.Y),math.rad(ppR.Z))) |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2017 03:18 PM |
well of course it sets the primary parts cframe, so its going to reset its rotation dont do that, instead do
local rotation = PrimaryCFrame - PrimaryCFrame.p
--set to CFPos * rotation |
|
|
| Report Abuse |
|
|