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: SetPrimaryPartCframe is rotating model?

Previous Thread :: Next Thread 
ASpoonfullOfSucrose is not online. ASpoonfullOfSucrose
Joined: 28 Oct 2015
Total Posts: 442
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 is online. 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 is not online. 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
ASpoonfullOfSucrose is not online. ASpoonfullOfSucrose
Joined: 28 Oct 2015
Total Posts: 442
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 is online. 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
ASpoonfullOfSucrose is not online. ASpoonfullOfSucrose
Joined: 28 Oct 2015
Total Posts: 442
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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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
ASpoonfullOfSucrose is not online. ASpoonfullOfSucrose
Joined: 28 Oct 2015
Total Posts: 442
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
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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
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