[ad_1]
Hey,
I’m at the moment engaged on a Game with a Tiny Wings/Dune like mechanic. Therefore I’m procedurally creating hills, that the participant is ready to dive&bounce on. Currently I’ve an array of vertices from which I draw the boundary of these hills on a Graphics object. I’m utilizing the identical vertices array to vary the polygon collider form to match the hills. Unfortunately it occurs very often that the polygon collider form (Box2D) attracts unusual strains, that shouldn’t be there. Here is a screenshot of my present challenge.
The purple line is the vertices array drawn with Lines on a Graphics object and the inexperienced space is similar vertices array (Just with some extra begin and endpoints to shut the form), drawn by the debug command:
PhysicsSystem2D.occasion.debugDrawFlags = EPhysics2DDrawFlags.Shape;
Currently there are roughly 180 vertices within the array. Do you’ve gotten any thought why that is taking place?
The replace code of the collider is as follows:
updateCollider(vertices: Vec2[]) {
const collider = this.node.getComponent(PolygonCollider2D);
collider.factors = [
new Vec2(vertices[0].x, 0),
...vertices,
new Vec2(vertices[vertices.length - 1].x, 0),
new Vec2(vertices[0].x, 0),
];
collider.apply();
}
Thanks to your help prematurely!
Hi, I don’t have a solution however simply wish to share my expertise doing the identical procedural logic (graphic + collider factors) and having lots of invisible (not deterministic) gaps the place the participant might fall. Sadly the one answer was to maneuver away from programmatic strategy and use simply a picture. Your sport seems to be good, hope you discover a method to do that and share it with us
[ad_2]