I’m having a weird issue that doesn’t make sense to me. I have a ship that shows a guide of where it is going to shoot. It does this by setting the start position of a line renderer to it’s position, then setting the second position of the line renderer to it’s position plus transform.up (it’s forward orientation in 2d) multiplied by 999.
This gives me a 999 unit line showing where it’s laser is going to go. Now, when it fires, it does the same thing. It shoots a circle cast from it’s transform, in the direction of transform.up (which, again, is it’s forward orientation in 2d space), with a width of it’s laser (0.21 is the radius) and has a distance of 999. This SHOULD cover the exact same space as the LineRenderer, but it doesn’t!
Now, I happen to know that the problem is the LineRenderer, and not the circle cast. If I move directly away from the ship that shoots, the guide laser starts to move to the side of the player, but the laser still hits the player. So the CircleCast is working as intended, but for some reason the line renderer doesn’t go “straight.”
The only explanation I can come up with is the difference between the LineRenderer taking an absolute position, and the CircleCast taking a direction. I don’t know why there would be a difference mathematically, though! They should end up as the same spot.
Any kind of explanation would benefit me fantastically.
You can see the full source code of the ship over at my Answers question here: LineRendered / Raycast not matching over distance - Questions & Answers - Unity Discussions
Also, you can download the game and witness the problem for yourself here: EAT by Unibear Studio
