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: what to use instead of GetModelCFrame?

Previous Thread :: Next Thread 
AkatUme is not online. AkatUme
Joined: 04 Mar 2012
Total Posts: 1598
25 Jul 2016 12:10 PM
im scripting something that would put a box that is the size of a model at the center of the model (like a selection box, kinda)

obviously i use getExtentsSize to get the size, but GetModelCFrame is deprecated, so what position should I use?

PrimaryPartCFrame wouldnt work b/c the primary part isnt at the center of the model..


I'm just a little rain cloud...
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
25 Jul 2016 12:12 PM
eugh that would be messy. if worst comes to worst you'd have to iterate through each part, add half of the size's y and half of the size's z and half of the size's x, see if that's the highest value so far, then do the same subtracting, see if that's the lowest value so far etc until you find the position of each corner of the model, then average them to find the centre.
Report Abuse
Lord_Narwhal is not online. Lord_Narwhal
Joined: 05 May 2012
Total Posts: 3242
25 Jul 2016 12:17 PM
why is getmodelcframe deprecated??


Add 13,000 posts
Report Abuse
AkatUme is not online. AkatUme
Joined: 04 Mar 2012
Total Posts: 1598
25 Jul 2016 12:19 PM
@Kodran nooo :(

@above idek


I'm just a little rain cloud...
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
25 Jul 2016 12:20 PM
You're talking about the finding the position of the model in the workspace?
I'd generate a reference part at the center of the model using

model = -- define it
modelSize = model:GetExtentsSize()
centerPoint = Vector3.new(modelSize.X/2,modelSize.Y/2,modelSize.Z/2)
part = Instance.new("Part",model)
part.Position = centerPoint
-- maybe weld it to the PrimaryPart? Depends on what you're going for
-- cframe "part" whenever you want to move the model

Something like that, I don't know if I used GetExtentsSize correctly.





Report Abuse
AkatUme is not online. AkatUme
Joined: 04 Mar 2012
Total Posts: 1598
25 Jul 2016 12:22 PM
@Soybeen thx for the help but that CenterPoint thing wouldnt work b/c the part wouldnt go to the center of the model unless the model was at 0,0,0


I'm just a little rain cloud...
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
25 Jul 2016 12:24 PM
Oh, duh

Uhhh there was a mathematical way to add up the positions and sizes of the parts to determine the center. I've only ever seen it a couple times and forget how to do it entirely.

Is that what Kodran described above?



Report Abuse
AkatUme is not online. AkatUme
Joined: 04 Mar 2012
Total Posts: 1598
25 Jul 2016 12:27 PM
ya D: rip me

thats too much work


ill just make the part myself and parent it in the model and work from therer :( rip


I'm just a little rain cloud...
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
25 Jul 2016 12:27 PM
It's super messy and just.. eugh.

http://wiki.roblox.com/index.php?title=API:Class/Model/GetExtentsSize

This method could prove useful though.
"If a PrimaryPart exists then the bounding box will be aligned to that part."

So just set a primarypart, then use that method then use that vector3 to find the centrepoint of your model like this:

model.PrimaryPart = somePartInModel
local myExtents = model:GetExtentsSize()
local centre = Vector3.new(somePartInModel+myExtents.X/2, etc)
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
25 Jul 2016 12:28 PM
by this:
somePartInModel+myExtents.X/2, etc)

I meant this:
somePartInModel.X+myExtents.X/2, etc)
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
25 Jul 2016 12:31 PM
Is it possible to just construct a Region3 using 2 parts of the model? Or is that impossible to find?


Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
25 Jul 2016 12:33 PM
Again, messy and eugh. You have to iterate through all parts in the model and find two opposite ends of the model then.. ew
Report Abuse
AkatUme is not online. AkatUme
Joined: 04 Mar 2012
Total Posts: 1598
25 Jul 2016 12:43 PM
ya there doesnt seem to be an ideal solution ;/


I'm just a little rain cloud...
Report Abuse
AkatUme is not online. AkatUme
Joined: 04 Mar 2012
Total Posts: 1598
25 Jul 2016 12:44 PM
ill try what kodran said tho

but even if the bounding box is aligned to the primarypart that doesnt mean the primary part is the center, right? dont they just mean rotation-wise? idk


I'm just a little rain cloud...
Report Abuse
Color3new is not online. Color3new
Joined: 05 Jul 2009
Total Posts: 64
25 Jul 2016 01:33 PM
Is there a problem with just sticking with GetModelCFrame()?
Yes, it has been deprecated and it isn't good practice to use deprecated things, but I don't really see a better alternative. It still works fine either way.

:remove() was deprecated ages ago and you still see it everywhere instead of :Destroy();
Report Abuse
WoolHat is not online. WoolHat
Joined: 19 May 2013
Total Posts: 1873
25 Jul 2016 01:40 PM
Destroy() is actually better for specific purposes. It locks the instance's parent to nil, and disconnects its corresponding events.

What annoys me is whenever roblox makes something helpful deprecated, and then don't substitute an alternative for it. In those cases, I recommend just using the deprecated method
Report Abuse
Color3new is not online. Color3new
Joined: 05 Jul 2009
Total Posts: 64
25 Jul 2016 01:43 PM
Sorry if my phrasing was off. I'm not saying that I prefer remove, just that I see it used everywhere still. I personally prefer to use Destroy for the reason you stated.
Report Abuse
WoolHat is not online. WoolHat
Joined: 19 May 2013
Total Posts: 1873
25 Jul 2016 01:51 PM
Oh :P both points are still valid though.
Report Abuse
AkatUme is not online. AkatUme
Joined: 04 Mar 2012
Total Posts: 1598
25 Jul 2016 11:31 PM
@Color3 Good point. Maybe I will use getmodelcframe regardless



I'm just a little rain cloud...
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