so I have a game that involves a lot of plants moving back and forth. each one of these plants has a script that makes them tween but it causes a lot of tweening lag. How would I go about making an Octree that only moves the plants when it needs to/ when you get close enough to the plant? I need to have this function because for some reason because of all the tweening the sun-like glitches when it moves and it never used to do that before all the tweening.
I have a folder with all the plants in it to hopefully make it easier for the octree. This makes some parts of my game lag even though I have a magnitude system.
I do not have any idea how to even make an octree so, I hope someone can help!
Let me know if you need any pictures of what things look like to maybe help figure this system out.
As an octree is a tree data structure in which each internal node has exactly eight children perhaps you could put the plants in groups of eight in a subfolder they are currently in and run one script that did the tweening of the children of each of those folders.
wherever you have the Plants currently stored in the explorer
create a folder called PlantCollections
within that folder create the first folder to contain 8 plants and call in Collection1
move the first 8 Plants into this folder.
Repeat the creation and move of 8 Plants to new folders with the name incrementing the number.
To access all the Plants use two loops based on GetChildren as seen in https://developer.roblox.com/en-us/api-reference/function/Instance/GetChildren
Process each plant within one script