I want to apply physics. Do you have any recommendations?

Avatar
  • updated

I want to Use Physics with your Shapes Plugin.

Will Unity Collider 2D work?

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
deianzen

Does this mean I need to implement a GetVertex() function for every type of Shape?
Is there a smarter approach, or has there been a recent update that helps with this?
I was considering using a vertex-related function from the parent class ShapeRenderer, but I couldn’t find anything that fits this use case.
I also considered using a Polygon Collider 2D for the Disc, but it seems to be more complex than expected.

Avatar
Freya Holmér creator

there's no built-in function for it, but it's relatively straightforward to mathematically calculate:

public Vector2 GetVertex( int i ) {
    float ang = i * ShapesMath.TAU / sides + angle;
    return ShapesMath.AngToDir( ang ) * radius;
}
Avatar
김홀 (Whiny)
Quote from Freya Holmér

sure! you can use whatever physics you want, Shapes is just a rendering library, and can be applied on top of whatever you're using

One more Question.

How can I get vertices of shapes?

rex)Regularpolygon can change shapes by sides and I want to get it.

Avatar
Freya Holmér creator

sure! you can use whatever physics you want, Shapes is just a rendering library, and can be applied on top of whatever you're using