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 would I get the current CFrame Rotation of a part?

Previous Thread :: Next Thread 
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
19 Jan 2017 02:51 PM
Title says all, also does anyone know if FindFirstChild() will search through the childrens children?
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
19 Jan 2017 02:59 PM
CFrame doesn't store rotation in the way you're thinking. If you want to deal with a rotation matrix, the various components of a part's rotation can be accessed in such a way using CFrame. Otherwise, if you're looking for a vector3 containing the degrees rotated in any given direction, use part.Rotation. And no, FFC doesn't search through children's children.
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
19 Jan 2017 03:00 PM
To clarify, CFrame can be easily used to make changes to a part's rotation, but the vector3 stored in the part's properties named Rotation is a more accessible way to find how a part is rotated in space at a given time.
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
19 Jan 2017 03:24 PM
what im trying to do here is when i clone a new model into the workspace it faces the same direction as a certain part, I was thinking of using :SetPrimaryPartCFrame()
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
19 Jan 2017 03:29 PM
:SetPrimaryPartCFrame(oldpart.CFrame) will work
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
19 Jan 2017 03:32 PM
I knew that, however I only need the rotation not the coordinates.
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
19 Jan 2017 03:34 PM
:SetPrimaryPartCFrame(CFrame.new(Vector3.new(Desiredpositionhere))*CFrame.Angles(oldpart's rotation, vector3))

copy the rotation vector from the part and paste it in the second cframe argument.

Make sure to convert to radians, i.e. if part has rotation (75,63,88) then input (math.rad(75),math.rad(63),math.rad(88))

Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
19 Jan 2017 03:34 PM
should be *CFrame.Angles(rotationvector3)

didn't mean to confuse things with that comma i wrote before
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
19 Jan 2017 03:35 PM
OP are you just trying to return a table of the rotation matrix?
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
19 Jan 2017 03:43 PM
@Un, no. My preview part has a body gyro and body position in it, because they arent 100% accurate I need to apply exact coordinates and rotation, here is my current code for this function.


function buildNewModel(ogModel)
local model = ogModel:Clone()
model.Parent = game.Workspace -----FIX THIS LATER
model:SetPrimaryPartCFrame(Preview.CFrame)
model:SetPrimaryPartCFrame(Vector3.new(round(mouse.hit.p.X)-2.5,round(mouse.hit.p.Y)+1.25-5,round(mouse.hit.p.Z)-2.5))
end

Report Abuse
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
19 Jan 2017 03:46 PM
Don't quote me on this, but you could create a variable.

local oldro = script.Parent.Rotation

script.Parent.Touched:connect(function(hit)
script.Parent.Rotation = CFrame.new(0,0,0)
end

script.Parent.TouchEnded:connect(function(hit)
script.Parent.Rotation = oldro
end

Something like that.


ATR'er since 2013.
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
19 Jan 2017 04:29 PM
bump, if only this post could get as much attention as my other one
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
19 Jan 2017 04:33 PM
is this 'round' a predefined function or are you referencing some math capability, because round isn't an automatic shortcut, perhaps math.ceil or math.floor
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
19 Jan 2017 04:35 PM
here is my round function

function round(numToRound)
local multiple = 5
local remainder = math.abs(numToRound) % multiple
if (remainder == 0) then return numToRound end
if (numToRound < 0) then
return -(math.abs(numToRound) - remainder);
else
return numToRound + multiple - remainder;
end
end

its job is to round to the nearest 5th stud
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
19 Jan 2017 04:46 PM
bump
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
19 Jan 2017 05:05 PM
please use this round function.
it will round it to the nearest 5.

function round(n)
local m=5
return n-(n%m)+math.floor((n%m)/m+0.5)*m
end


Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
19 Jan 2017 05:19 PM
can anyone help fix my code??
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