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: Help with :Resize()?

Previous Thread :: Next Thread 
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
19 Feb 2016 01:47 PM
I'm working with :Resize() and have been using it to resize Parts to meet the Position of PartA.
The only problem is that :Resize() is not performing accurately for some reason.
There is either a gap of about 0.2 above or below the Position of PartA, and I don't know how to prevent this.

Here's the equation I've been using to determine the "GrowthSize":
local PlusGrowth = (CurrentY - game.Workspace.BasePlate.Position.Y) - HalfPartSize

This is later followed by:
MainPart:Resize(Enum.NormalId.Bottom, PlusGrowth)=

Any help or advise as to how I can prevent this problem would be greatly appreciated.
Report Abuse
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
19 Feb 2016 01:48 PM
(PartA is the named BasePlate, by the way)
Report Abuse
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
19 Feb 2016 01:52 PM
you would need re-position it too.
Report Abuse
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
19 Feb 2016 01:56 PM
@myactivestplace

Considering :Resize() takes a Surface as a parameter and expands on that Surface, I don't believe you would have to change the position of anything.
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
19 Feb 2016 01:56 PM
Resize will not resize a part if the part would hit another part.

You would need to make a function to resize it yourself
Luckily for you I already did that a while back

example;
local part = Instance.new("Part", workspace)
part.Name = "part"
for x = 1, 1000, 1 do
addSize(part, 1, Enum.NormalId.Front)
wait()
end

Here is the function

local function addSize(basePart, x, direction)
local cframe, size = basePart.CFrame, basePart.Size

basePart.Size = (basePart.Size + ((((direction == Enum.NormalId.Top) or (direction == Enum.NormalId.Bottom)) and
Vector3.new(0, x, 0)) or
((((direction == Enum.NormalId.Front) or (direction == Enum.NormalId.Back)) and
Vector3.new(0, 0, x)) or
(((direction == Enum.NormalId.Right) or (direction == Enum.NormalId.Left)) and
Vector3.new(x, 0, 0)
)
)
))

basePart.CFrame = (cframe + ((((direction == Enum.NormalId.Top) and
(CFrame.new(cframe.p, (cframe * CFrame.new(0, 1, 0)).p).lookVector)) or
(((direction == Enum.NormalId.Bottom) and
(CFrame.new(cframe.p, (cframe * CFrame.new(0, -1, 0)).p).lookVector)) or
(((direction == Enum.NormalId.Front) and
(CFrame.new(cframe.p, (cframe * CFrame.new(0, 0, -1)).p).lookVector)) or
(((direction == Enum.NormalId.Back) and
(CFrame.new(cframe.p, (cframe * CFrame.new(0, 0, 1)).p).lookVector)) or
(((direction == Enum.NormalId.Right) and
(CFrame.new(cframe.p, (cframe * CFrame.new(1, 0, 0)).p).lookVector)) or
(((direction == Enum.NormalId.Left) and
(CFrame.new(cframe.p, (cframe * CFrame.new(-1, 0, 0)).p).lookVector))
)
)
)
)
)
) * (((((direction == Enum.NormalId.Top) or (direction == Enum.NormalId.Bottom)) and
(basePart.Size.Y - size.Y)) or
((((direction == Enum.NormalId.Front) or (direction == Enum.NormalId.Back)) and
(basePart.Size.Z - size.Z)) or
(((direction == Enum.NormalId.Right) or (direction == Enum.NormalId.Left)) and
(basePart.Size.X - size.X)
)
)
) / 2)))
end
Report Abuse
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
19 Feb 2016 02:02 PM
@128Gigabytes

Thanks. I appreciate your suggestion, however my the code does work at the moment, it is simply inaccurate.

I use CanCollide = false, run the code, CanCollide = true to get what I believe is the same effect as what you've suggested.

Any other suggestions?
I really am baffled by the fact that there are these tiny gaps.
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
19 Feb 2016 02:10 PM
That is very interesting I didn't know resize would consider a part to not be in the way if its canCollide property was false.

I would still suggest not using resize() in case other parts are in the way, like a player.

As for your problem, is there a reason you can not make mainPart as long as the distance between mainPart and the other part, then position it halfway between mainPart and the other part, and make it face the other part?
Report Abuse
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
19 Feb 2016 02:15 PM
@128Gigabytes

That's a nice idea that I didn't think of before.
Ideally, I'd like to get this :Resize() problem resolved as I'd rather not redesign the system I've got working.

Do you think that would be most efficient? (i.e."make mainPart as long as distance.." suggestion)
Might be the same difference, I'm not sure.
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
19 Feb 2016 02:26 PM
local mainPart = workspace.Part
local otherPart = workspace.Baseplate

mainPart.Size = Vector3.new(1, 1, (mainPart.Position - otherPart.Position).magnitude)
mainPart.CFrame = CFrame.new(((mainPart.Position + otherPart.Position) / 2), otherPart.Position)
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
19 Feb 2016 02:40 PM
Oops
Change
((mainPart.Position + otherPart.Position) / 2)

To

mainPart.Position:lerp(otherPart.Position, 0.5)
Report Abuse
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
20 Feb 2016 08:30 AM
I know what the problem is!

The amount of studs that Part is being resized by is always an even number for some reason.
For example, one Part resized to a Y Size of 188, when it should have been 188.25.

Any idea why that is?
Does Resize() only allow whole numbers?
Report Abuse
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
20 Feb 2016 08:33 AM
Yep, just checked the Wiki.
:Resize() accepts integers only :(

So what is the most efficient alternative?
Gigabyte's suggestion?
Report Abuse
adzz123 is not online. adzz123
Joined: 11 Jun 2011
Total Posts: 260
20 Feb 2016 08:37 AM
There probably is another way but Gigabytes code is relatively simple. Just add comments.


There are 10 types of people in this world. Those that understand binary and those that don't.
Report Abuse
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
20 Feb 2016 08:39 AM
Just tested Gigabyte's code.
Everything is resized in the direction of the centre of the Baseplate, rather than straight down.
Any ideas how that could be fixed?
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Feb 2016 12:09 PM
I didn't know it only took integers

My addSize function will take whatever number, so that could fix it

Report Abuse
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
20 Feb 2016 12:59 PM
warspyking told me this efficient way of solving the problem.
It's pretty short and works perfectly!

Here's the code:

local Resize
do
local directions = {
[Enum.NormalId.Top] = {Scale=Vector3.new(0,1,0),Position=Vector3.new(0,1,0)},
[Enum.NormalId.Bottom] = {Scale=Vector3.new(0,1,0),Position=Vector3.new(0,-1,0)},
[Enum.NormalId.Right] = {Scale=Vector3.new(1,0,0),Position=Vector3.new(1,0,0)},
[Enum.NormalId.Left] = {Scale=Vector3.new(1,0,0),Position=Vector3.new(-1,0,0)},
[Enum.NormalId.Front] = {Scale=Vector3.new(0,0,1),Position=Vector3.new(0,0,1)},
[Enum.NormalId.Back] = {Scale=Vector3.new(0,0,1),Position=Vector3.new(0,0,-1)},
}

function Resize(p, d, n, c)
p.Size = p.Size + directions[d].Scale*n
local prop = c and 'Position' or 'CFrame'
p[prop] = p[prop] + directions[d].Position*(n/2)
return p.Size, p[prop]
end
end


Resize(workspace.Part, Enum.NormalId.Bottom, 10, false) --Resize workspace.Part downards by 10 studs, ignoring collisions
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Feb 2016 01:07 PM
That resize function does not work properly.
Report Abuse
Craftero is not online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
20 Feb 2016 01:24 PM
@128Gigabyte

That's very strange.
It works perfectly for me.

Why is it not working for you?
Are you receiving any errors?
Report Abuse
128Gigabytes is online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Feb 2016 01:37 PM
https://www.youtube.com/watch?v=uezFMu_lql4
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