Reputation: 23
I am working on a little 2d Top-view game project with Unity 2022.2.20
my player is a hacker who needs to hack stuff.
I am representing the hack being done with a GameObject
(named Hackray) that has a LineRenderer
component.
I've set up a Y-Axis sorting and I am rendering all the sprites in the environment.
I changed all the SpriteRenderer
Sort point to Pivot and sprites pivots to BottomCenter to make my game render well.
However, since the Hackray is drawn through a LineRenderer
, its sorting is by default based on its Center, and I don't know how to change that.
It causes a visual bug like this :
As you can see, when the center of the HackinRay has a Y value greater than the Computer bottom, the Computer is rendered after the HackinRay.
I would then like to change the LineRenderer
Sort Point to a Custom Point (the center of the player's sprite would be perfect), but I don't know how I can do this.
I've searched a lot on internet about this but it seems very complicated to change Sort Point in unity, even with SpriteRenderer
I can not change it to a Custom Point.
Is there a way to fix this ? Should I rather create a new custom script and render the line with a SpriteRenderer
?
And also I don't really understand the differences between those "Texture Modes" :
The doc of unity explains it maybe well but I don't understand what differences bring DistributePerSegment
and
RepeatPerSegment
.
Upvotes: 0
Views: 53
Reputation: 23
Alright seems like it is easier to achieve with a custom script using SpriteRenderer.
If you face the same problem, do not forget to change the pivot to BottomCenter in the Sprite Editor and then select Pivot for Sprite sort point and you should be fine.
Upvotes: 1