|
| 16 Feb 2016 06:56 PM |
Title is just because I need people who know what they're doing with CFrame.
I need to move a model by its center of it bounding box. I've been struggling with this for days, please help.
#code while wait(1) and x > madness do x = x - 0.01 end |
|
|
| Report Abuse |
|
|
| |
|
|
| 16 Feb 2016 06:59 PM |
Doesnt work for what im doing.
#code while wait(1) and x > madness do x = x - 0.01 end |
|
|
| Report Abuse |
|
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
|
| 16 Feb 2016 06:59 PM |
u could always use GetModelCFrame() and SetPrimaryPartCFrame()
ill do it without primary part if u insist
|
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 06:59 PM |
| And why's that? You want to move it from it's center, and that does exactly what you want. |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:02 PM |
Translate moves it, it doesnt give me any position information. How can I do this without without a primary part?
#code while wait(1) and x > madness do x = x - 0.01 end |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:04 PM |
| What do you mean position information? What is wrong with you? If you need to move it from the center, this is EXACTLY what you want. Model:TranslateBy(amnt) |
|
|
| Report Abuse |
|
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
|
| 16 Feb 2016 07:18 PM |
function MoveModel(model,cf) local mcf = model:GetModelCFrame() local function search(t) for i=1,#t do if t[i]:IsA("BasePart") then local o = mcf:inverse()*t[i].CFrame print(o.p) t[i].CFrame = cf*o end search(t[i]:GetChildren()) end end search(model:GetChildren()) end
works as far as I can see
Unstable's solution might be suitable, but it uses Vector3s and I believe that the function will be aware of collisions
Mine can be a little expensive though, so don't plan on running it a lot
|
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:20 PM |
@rvox
I was under the impression that it wouldn't. Let me run a quick test. |
|
|
| Report Abuse |
|
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
|
| 16 Feb 2016 07:22 PM |
Actually it ignores collisions
nonetheless, it does not use CFrames
|
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:23 PM |
I was aware of that (that it doesn't use CFrame).
Anyways, it seems collisions don't register. However, I had a weird effect. Somehow, it collided 0.5 studs into the part above it (or should have), but instead they BOTH rose 0.5 studs. Quite odd. |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 16 Feb 2016 07:28 PM |
Less expensive 4 u
local function MoveModel(model,cf) cf = cf*model:GetModelCFrame():inverse() local temp = model:GetChildren() for _, obj in ipairs(temp) do if obj:IsA("BasePart") then obj.CFrame = cf*obj.CFrame end for _, child in ipairs(obj:GetChildren()) do temp[#temp+1] = child end end end |
|
|
| Report Abuse |
|
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
|
| 16 Feb 2016 07:34 PM |
wtf i did not know tht method to serch thru everything
|
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:36 PM |
ipairs is so bad... use next.
for i,v in next, table do -- stuff end
#code R+ | local RAP = "R$423,184"; local robux = "R$13,865" |
|
|
| Report Abuse |
|
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
|
| 16 Feb 2016 07:37 PM |
abstract dont start tht argument
numerical loops > all
|
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:38 PM |
LOL but rly next > all
numerical loops r just rly bad because the thing ur looping thru isnt already defined... u gotta do tbl[i] which looks horrid... get back to 2016, not 2011 jfc
#code R+ | local RAP = "R$423,184"; local robux = "R$13,865" |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 16 Feb 2016 07:39 PM |
| It's magical. No need for extra function calls//scoped function creation. Also is a better choice to recursion (in this instance) as Roblox doesn't support tail calls which means you can cause a stack overflows via recursive functions. |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:56 PM |
| Ughhh.... Oh my god, thanks rvox and casual. You guys typically pull through for me. Explain why that works so I don't have to figure it out on my own? ::)) |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:59 PM |
| No thanks for me, when even rvox said it works? Just wow, wow. Your an ungrateful child. |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:59 PM |
| CFrame is what I need a explain action of. Also nice recursion meow casual |
|
|
| Report Abuse |
|
|
|
| 16 Feb 2016 07:59 PM |
| It still works, regardless of whether it takes Vector3's or CFrames. |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 17 Feb 2016 02:33 AM |
>> It still works, regardless of whether it takes Vector3's or CFrames.
While your solution doesn't error and therefore meets the minimum definition of working, it is not comparable to posted and accepted solution since it cannot handle rotation and by your own admittance isn't 100% reliable (i.e weird effect).
>>No thanks for me, when even rvox said it works? Just wow, wow. Your an ungrateful child.
OP specifically wanted to move things via CFrame. We provided the appropriate CFrame transformation function. You provided a Vector3 translation function (merely quoted the API), which OP probably already looked at when researching the problem.
OP is not an ungrateful child, as evinced by OPs expression of gratitude for the solution they were looking for. Your solution just wasn't what they wanted, move on. |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2016 06:15 AM |
> What do you mean position information? What is wrong with you?
Lol, translate by doesn't work because of what I'm doing. I need to be able to move models to very specific points for 3D guy tiling and translate by doesn't work. If this isn't already obvious to you, translate by doesn't work because the origin as well as the position of models in ReplicatedSotrage vary slightly which doesn't turn out good when tiling.
Drop the attitude skid, you're not cnt don't think you can act like cnt. |
|
|
| Report Abuse |
|
|
|
| 17 Feb 2016 06:18 AM |
There is only one cnt, and he does not share power.
|
|
|
| Report Abuse |
|
|
|
| 17 Feb 2016 06:18 AM |
IDK what this thread is for. So I'm just going to start a chain.
^ |
|
|
| Report Abuse |
|
|