I am working on a device that adds water to an area, and more specifically, the preview of the area where the water is going to be added.
When the size attribute changes, the part changes size, but it ignores its pivot point to keep it on the ground, what can I possibly change to this line to solve this issue?
script.Parent.AttributeChanged:Connect(function()
script.Parent.Zone.Size = script.Parent:GetAttribute("AreaSize")
end)
Here is an illustration describing what I want:
1 Like
SelDraken
(SelDraken)
June 28, 2021, 1:23am
#2
I think I remember in the docs for pivot points that they need to be repositioned after a scale operation.
How do I change the pivot point so it correctly fits when sized by script? (Sizing in studio makes the pivot change automatically)
SelDraken
(SelDraken)
June 28, 2021, 1:30am
#4
maybe try to scale the pivot position by the same scale that is applied to the part. See what result that gives.
I cannot find a way to change the pivot position at all
SelDraken
(SelDraken)
June 28, 2021, 1:57am
#6
Property CFrame BasePart.PivotOffset
Property CFrame Model.WorldPivot
We’re introducing pivot points to Roblox Studio. With this change you will be able to set the point around which each part and model in Roblox Studio is translated / rotated. You can enable pivot points via the Pivot Editor beta feature now available in the Beta Features panel:
[image]
Sounds simple right? Well, strap in, because there’s actually a lot to unpack between the feature’s visuals, tooling, APIs, and future implications.
Team Create Restriction
EDIT: The APIs are available everywh…
tnavarts
(tnavarts)
June 28, 2021, 1:59am
#7
See the above. Don’t worry, we’re writing up detailed documentation on pivots right now to have on the DevHub before we release pivots from beta.
4 Likes
dukzae
(dukzae)
June 28, 2021, 2:01am
#8
Alternatively, you could experiment with some math:
local function resizeUpward(part,studs)
local s = part.Size
part.Size = Vector3.new(s.X,s.Y + studs,s.Z)
part.CFrame *= CFrame.new(0,studs/2,0)
end
The preview just sized negatively somehow
It did not really get into negative numbers, it just sized down somehow
resizeUpward(script.Parent.Zone, script.Parent.Zone.Size.Y - script.Parent:GetAttribute("AreaSize").Y/2)
I have messed a bit with the function code, turns out there is something about the CFrame division that is getting funky with how the preview goes up
Also also, it just keeps growing upwards each time I edit the zone value thing
SelDraken
(SelDraken)
June 28, 2021, 2:14am
#10
If all you are wanting is for the preview to be on the ‘ground’ no matter what the scale, can you not just adjust its position to 1/2 of its size in the Y direction?
preview.cframe = cframe.new(x , y + (preview.size.y/2), z)
or something like that?
That just keeps adding to the height position every time the size is changed
tnavarts
(tnavarts)
June 28, 2021, 3:16am
#12
Here’s what you want:
local function scaleCFrame(cframe, scale)
local position = cframe.Position
local rotation = cframe - position
return rotation + position * scale
end
local oldPivot = part:GetPivot()
part.Size = part.Size * scale
part.PivotOffset = scaleCFrame(part.PivotOffset, scale)
part:PivotTo(oldPivot)
3 Likes
What exactly do I have to put in the scale?
Hold on a minute, roblox staff!?
Edit: Nothing is working and I am stressed, I need to know what to put in ‘Scale’
Well, it seems I have been stranded here.
1 Like
sadly there isnt any solution this is how roblox functions sadly i believe that they created this feature only for builders and not scripters