WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 04 Aug 2015 12:44 PM |
I made a (functioning :D) script that resizes two blocks in a model from only one direction, until they are visibly touching. This all works, but if either blocks are touched while resizing, they jump up to the first open spot they can find. Kind of like when you do vector3 changes without CFrame. Here's the script:
local Part1 local Part2 local waitTime = 0 local expansionIncrement = 0.05 local additive
function calcSizeDiff() if Part1.Size.Z > Part2.Size.Z then additive = math.abs(Part1.Size.Z - Part2.Size.Z) / 2 elseif Part1.Size.Z < Part2.Size.Z then additive = math.abs(Part1.Size.Z + Part2.Size.Z) / 2 elseif Part1.Size.Z == Part2.Size.Z then additive = 0 end end
function assignPartVars() for i,v in pairs(script.Parent:GetChildren()) do if v:IsA("Part") and Part1 == nil then Part1 = v elseif v:IsA("Part") then Part2 = v end end end
function runDrive() while math.abs(Part1.Position.Z - Part2.Position.Z) > Part2.Size.Z + expansionIncrement*2 + additive do Part1.Size = Part1.Size + Vector3.new(0, 0, expansionIncrement) Part1.CFrame = Part1.CFrame + Vector3.new(0, 0, expansionIncrement/2) Part2.Size = Part2.Size + Vector3.new(0, 0, expansionIncrement) Part2.CFrame = Part2.CFrame + Vector3.new(0, 0, -expansionIncrement/2) wait(waitTime) end end
assignPartVars()
calcSizeDiff()
runDrive()
If anyone can give me a solution to fix the jump-up issue, I'd be very appreciative :) Thanks |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 01:10 PM |
| why wouldnt you just cframe than? |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 04 Aug 2015 01:35 PM |
| Well, I need the size to change too. If I just do the CFrame, it'll move two blocks in the same direction. With this, one face of the block stays in the same position while the other expands |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 01:39 PM |
| its just plus and minus on the same axis like this (1,0,0) (-1,0,0) will go opposite ways |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 04 Aug 2015 01:45 PM |
Mine is a bit more complex than just making them move in opposite directions
This is what mine does: http://gyazo.com/0c329f99a9dbe0454d71f430c264251d This is what just with CFrame does: http://gyazo.com/ad3f6f2f0190e318b3ff874062c05a30 |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 04 Aug 2015 01:46 PM |
| Of course, I did make a formula that it stops just a hair before the two doors actually touch and one flies up. But, if any part gets in their way, they jump. |
|
|
| Report Abuse |
|
|
Stefan631
|
  |
| Joined: 23 Dec 2010 |
| Total Posts: 1350 |
|
|
| 04 Aug 2015 02:15 PM |
| you realize there's a :resize method of basepart..? |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 04 Aug 2015 02:41 PM |
@Stefan No, I don't, because the wiki doesn't make stuff like that very clear -.-
But that's not your fault. I appreciate the answer Stefan! :D |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 04 Aug 2015 02:51 PM |
But, question of the :Resize() method.. According to the wiki, there's two arguments. First one is which face, second argument is the increment. I replaced a section within the while loop (part that changes the position and size) with this:
Part1:Resize(2,0.05) Nothing happens, even though everything else continues to work. No output. Am I doing something wrong?
The "2" is the value for the side, by the way. |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2015 02:57 PM |
When you resize, Either the X, Y, or Z axis gets expanded and 50% in each direction.
Say we have a 1x1x1 part. It is at 0,0,0
We resize the part 1x0x1 Position should now be at 0.5,0,0.5 or something like that. |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 04 Aug 2015 03:15 PM |
| Resize works in the direction I want, thankfully. Now, though, the minimum resize increment is 1. I searched the wiki, it said that the ResizeIncrement is a read-only value, and cannot be changed. very little scripture for anything along the lines of changing, if any. |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 09 Aug 2015 08:55 PM |
Is a 5 day old thread too old to bump?
Anyways, does anyone know how to make the resizeincrement smaller? Or if there is a way to keep a block from jumping up when something touches it during resize? |
|
|
| Report Abuse |
|
|