I’ve been experimenting with methods of detecting when a viewport frame is visible inside a ScrollingFrame. So far this is what I got. It really doesn’t work most of the time. If you have any tips on how to do this please let me know.
local StartPos = script.Parent.CanvasPosition.X
local EndPos = (script.Parent.CanvasPosition.X + script.Parent.AbsoluteWindowSize.X)
for _,viewport in pairs(script.Parent:GetChildren()) do
if viewport:IsA("ViewportFrame") then
local startviewpos = viewport.AbsolutePosition.X
local endviewpos = viewport.AbsolutePosition.X + viewport.AbsoluteSize.X
if (startviewpos >= StartPos) or (endviewpos <= EndPos) or (startviewpos <= EndPos) or (endviewpos >= StartPos) then
viewport.LoadViewport.Value = true
else
viewport.LoadViewport.Value = false
end
end
end
Take a look at this article by EgoMoose. It covers how to detect when two 2D objects intersect. In your case, you’re finding if the ViewportFrame intersects with the ScrollingFrame. https://developer.roblox.com/articles/2D-Collision-Detection
It has been a while on this post, I was wondering if you can explain how and what you are doing to check this, Do you use while loops every frame or detect scroll change to make it do the loop?