Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add per-Danmaku scaling #36

Open
Jonath opened this issue May 11, 2018 · 3 comments
Open

Add per-Danmaku scaling #36

Jonath opened this issue May 11, 2018 · 3 comments

Comments

@Jonath
Copy link

Jonath commented May 11, 2018

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).

@james7132 james7132 changed the title Scaling Add per-Danmaku scaling May 11, 2018
@james7132
Copy link
Owner

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.

@Jonath
Copy link
Author

Jonath commented May 11, 2018

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.

@james7132
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants