Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

WARNING: technical rant incoming!

So my basic implementation for the Shodos (brush strokes on screen) is to use a LineRenderer and a PolygonCollider2D that are continuously updated by pointer position (either mouse or touch).

I'm basically mimicking a TrailRenderer (+Collisions) with my LineRenderer. I don't use a TrailRenderer though because then I would have less control over the vertices of the trail (which I have to keep in sync with the collider), and also because TrailRenderer "remembers" the time it took you to draw each segment, and I want it to "erase" and resize at a steady pace, regaurdless of how long it took to draw the line.

Before this jam I tried to make my own LineRenderer from scratch for this purpose (using a Mesh and setting my own vertices, uvs and triangles). but that lead me down a rabbit-hole of Vector math and unforseen situations. I ended up with something that mostly works (minus texture mapping, didn't want to waste more time fixing uvs), and I abandoned it because it was getting way out of scope.

anyway how I'm doing it now looks like this- I break down each bush stroke to "Slices":



with each slice having a Vector3 Center (that goes to the LineRenderer), two edges in a Vector2[] Array (For the PolygonCollider), and a width (that defines the edges).

(Slices are perpendicular to the direction that the line is going at the particular moment they're calculated)

I also made a Slicelist class that holds a list of slices as well as lists for line vertices, polygon vertices, and widths, and it synchronises between them (the idea is that besides the creation of Slices, all vertex-level stuff (adding slices, resizing, deleting) is done using SliceList methods, so that the Shodo class can be much more readable and editable)

Anyway, I'ts not really functional yet, but it's getting there. I just hope it's not going to be too unoptimised since I have to use List.ToArray() 3 times per frame for each of the Shodos I have on screen (to set them in the actual LineRenderer/PolygonCollider2D)


So yeah, sorry for the technical rant, but this feels like a good outlet to not let this stuff just sit in my head, so it's probably not gonna be the last haha

Also if anyone has any comments or suggestions I would love to hear them

(+1)

Doing List.ToArray three times a frame should be alright, assuming they're not nested calls or something crazy. I like the implementation you've done with the slices, looking forward to seeing how it works out.