DanmakU
DanmakU copied to clipboard
Add per-Danmaku scaling
Potentially 2 types :
- With a single float value, applying to both x and y (uniform scaling)
- With a Vector2, to change both x and y (independent scaling)
The advantage of solution 2 is that you could simulate the rotation of a bullet around an axis with a behaviour. (for instance scaling down X or Y to zero to make it look like it's rotating around the X or Y axis).
This has several components that need to be implemented:
- Adding an additional scale factor into rendering.
- Scaling the collision boundaries for each bullet.
The latter seems to be difficult to handle with non-uniform scaling.
I agree scaling a collider could be expensive, and also inaccurate for option 2. AABB and OOB should actually scale pretty nicely (although AABB could become very big). Circle won't scale well at all in case 2 (r = min(X,Y) will be inaccurate, and ellipse collision is terrible).
Maybe this should rather be defined by an empiric jobified behaviour depending on the pattern ? Thus, something to leave to the user to implement.
Under the hood, we use a two pass collision algorithm: an initial AABB check against colliders, and then call Physics2D.CircleCastNonAlloc to do fine grain collision detection.
While computing AABBs for scaled offset circles is trivial, it does significantly complicate the code for this section of the algorithm.
The second part is the worrying one: Physics2D.CircleCast* calls do not support arbitrary non-uniform scaling.
For the time being, it should be possible to add at least uniform scaling without any major roadblocks.