So a few days ago I made this handy effect where any physical object intersecting this 2D line would highlight it. It works, but my concern is that it could get expensive very quickly because of how it calculates it behind the scenes.
It’s not fully obvious but the way it works is that it simulates a 2D hitbox for each object, and then casts a 2D raycast from both ends of the line to check if there’s an intersection.
The reason why I think it’s expensive is because it calls :WorldToViewportPoint a lot for creating the 2D hitbox, and a lot more calculations for the 2D raycast, every frame.
If anyone has any ideas on how to optimize this, let me know!