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 » Scripting Helpers
Home Search
 

CFraming a model.

Previous Thread :: Next Thread 
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
24 Mar 2014 08:41 PM
Simple as the title.

MoveTo() Doesn't work on CFrames.
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
24 Mar 2014 08:46 PM
...
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
24 Mar 2014 08:49 PM
Elaborate on the CFrame part.
You want to keep the angle?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
24 Mar 2014 08:49 PM
*Change the angle
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
24 Mar 2014 08:49 PM
Basicly, I want the center of a model, where a certain part is.
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
24 Mar 2014 08:50 PM
function RotateModel(Model, Mid, Angles)
for i, v in pairs(Model:GetChildren()) do
if v:IsA("BasePart") then
v.CFrame = Angles:toWorldSpace(Mid:toObjectSpace(v.CFrame))
end
RotateModel(v, Mid, Angles)
end
end

-- example
local mid = model:GetModelCFrame()

RotateModel(model, mid, mid * CFrame.Angles(x, y, z))
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
24 Mar 2014 08:51 PM
Is there a simple way for me needs..? I just want to move it not rotate.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
24 Mar 2014 08:51 PM
Ell, if you want to move models with CFrame, you can scroll in my my models list and find my Model Mover script.


You'll find some weird stuff while scrolling through, though.

To get the center of a model:
http://wiki.roblox.com/index.php?title=GetModelCFrame_(Method)
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
24 Mar 2014 08:52 PM
Oh

for i,v in pairs (Model:GetChildren ()) do
v.CFrame = v.CFrame + CFrame.new (blah,blah,blah)
end
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
24 Mar 2014 08:53 PM
I'm an idiot.. I mean that's so simple is like.. obvious. That's 20 minutes of searching wasted

Thanks..
Report Abuse
databrain is not online. databrain
Joined: 01 Jan 2013
Total Posts: 3342
24 Mar 2014 08:54 PM
http://wiki.roblox.com/index.php/User_talk:NXTBoy/Scripts/Model_CFrame
Report Abuse
roboslayer10 is not online. roboslayer10
Joined: 08 Aug 2011
Total Posts: 206
24 Mar 2014 09:03 PM
function move(model,position)
parts = {}
for i,v in pairs(model:GetChildren()) do
if v:IsA("Part") then
table.insert(parts,v)
elseif v:IsA("Hat") or v:IsA("Tool") then
if v:FindFirstChild("Handle") then
table.insert(parts,v.Handle)
end
end
end
local t = model:GetModelCFrame()
local x = position.X - t.X
local y = position.Y - t.Y
local z = position.Z - t.Z
t.CFrame = t.CFrame + Vector3.new(x,y,z)
for i,v in pairs(parts) do
v.CFrame = v.CFrame + Vector3.new(x,y,z)
end
end

probably an inefficient script, but idc. lol. Just say move(model,position) to get it work.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Mar 2014 09:04 PM
object space, look it up. No need to be super complicated
Report Abuse
roboslayer10 is not online. roboslayer10
Joined: 08 Aug 2011
Total Posts: 206
24 Mar 2014 09:05 PM
true.

CFrame:toWorldSpace()
and
CFrame:toObjectSpace()

have always been my enemy.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Mar 2014 09:07 PM
toWorldSpace is super simple, it's just multiplying the cframe with the argument.
toObjectSpace just gets the inverse and multiplies it by the argument.
Report Abuse
roboslayer10 is not online. roboslayer10
Joined: 08 Aug 2011
Total Posts: 206
24 Mar 2014 09:08 PM
yeah I messed around with toWorldSpace alot, but never fiddled enough with toObjectSpace.

Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Mar 2014 09:10 PM
Think of worldSpace as "relative to itself"
and objectSpace as "relative to another CFrame"
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
24 Mar 2014 09:14 PM
Okay how do I select a random position from a table?

Let's say one position is (10,10,10), how would I store that in a table and take it.



Table = {PosOne,POSITIONABOVE,PosTwo,POSITIONABOVE,ect..}

for i,v in pairs (Dino:GetChildren ()) do
v.CFrame = v.CFrame + CFrame.new (Table#)
end
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Mar 2014 09:19 PM
local list = {Vector3.new(10,10,10), Vector3.new(5,5,5), ...}

local selected = list[math.random(#list)]
for i, v in pairs(Dino:GetChildren()) do
v.CFrame = v.CFrame * CFrame.new(selected)
end
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
24 Mar 2014 09:20 PM
I really need to learn more bout tables.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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