I’m trying to predict and visualize where an object will go, and I’ve managed to make it work.
The issue however is with visualizing; ~80-90% of the frame drops I get are from rendering just 256 images in workspace.
I’m currently using attachments and beams for each line segment in between two points, everyone knows parts will already be very laggy and BillboardGuis always face the camera, so they wouldn’t even show up the way I want to.
I don’t know how else I can do this. They’re basically just 2D line sprites after all, surely Roblox has a way to make this possible without significantly affect framerate…?
You can try reducing the number of line segments to improve performance. One way to do this is to use a technique called “spline interpolation” to smooth out the path of the object, reducing the number of line segments needed to represent it accurately. Another option is to use a single line part instead of multiple attachments and beams. This will reduce the number of objects being rendered and should improve performance.
Another technique you can try is to use decals instead of attachments and beams. Decals are 2D images that can be placed on surfaces. You can use them to create a continuous line between two points, and they have a lower performance impact than parts or attachments.
Finally, you can try using a third-party library, such as Roact or Rodux, to manage the rendering of your lines. These libraries are designed to optimize rendering and should help improve performance.
Although reducing the number of lines would improve performance, it also lowers accuracy, which I can’t sacrifice for this specific scenario.
Splines take a certain number of points and return more in the end. Although it would smooth the curve, it would only do that because it’d create more points and therefore more lines.
Decals and Textures can only go on surfaces, as you said. This means I’d have to use parts, which will be a lot less performant than beams, which just need attachments. Decals/Textures can also only be seen on one face of an object at a time too, so it wouldn’t work very well even if using parts was a viable option.
If Roact or Rodux have a way to render 2D images in a 3D space that’s more efficient, that means they’re using an engine feature I should also be able to use without getting them, as they both just libraries.
Also, your formatting and explaining oddly reminds me of ChatGPT… Did your run my post through that as a prompt?
ignoring the ai generated response You can effectively achieve this using parts with little to no performance impact:
Utilise a part caching system. By creating a ton of parts ahead of time and positioning them hundreds of thousands of studs away, you can effectively store them and “create” many parts at once without the costly overhead of cloning new parts or reparenting them.
Use BulkMoveTo to quickly set the CFrames of all the parts associated with the visualisation. You can change any properties (size, colour, transparency etc.) before or after this process.
Return parts to the part cache once they’re no longer needed so they can be reused in another visualisation!
You will end up with stuff like z-fighting if the visualisation parts have any form of transparency, but other than that it should perform pretty well! The biggest drops in performance in regards to parts tend to come from cloning or reparenting of parts rather than the rendering, which tends to be pretty performant.
The only other way I could imagine squeezing more performance out of it depends on how you want to visualise it. If it would be a flat double sided plane then you could utilise a special single face MeshPart made up by only two triangles, then enable DoubleSided which would equate to 4 triangles per part, compared to 12 for a regular Part. A very nice reduction!
Have you tried Rope, Rod or Spring Constraints? They are placed between Attachments as well, but I’m not sure if they would be less or more performant.
I’m can’t remember if Rods or Ropes will ‘fit’ between anchored Attachments if the lengths are different. Springs will if you set the Radius of the coils to 0 and the Thickness to whatever size you need. They’ll display like a rod, but the length won’t matter.