Polygonal Collision not working

NerdinaNutshell

  • Posts: 251
Using Stencyl 4.0.2. Trying to use the add polygonal collision shape to actor block, but the collision doesn't work in most sections of the collision and in the one section it does (as seen in the picture) the actor goes into the collision box slightly. Is this an issue on my part, is this an issue with the engine? Thanks.
*Puff*

Luyren

  • *
  • Posts: 2810
Unless I'm mistaken, the blocks to add a polygon collision shape are in actor coordinates, meaning 0,0 is the top left corner of your actor. From what I can see from your code, one of the points hast its X set to "Half scene width", and if it matches the actual half width of your scene, that's how far the point is from your actor.

I can't see the rest of your code, but it does seem it's an issue on your part instead of Stencyl's. You could try creating a simple and smaller polygon and see how it interacts with everything.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

merrak

  • *
  • Posts: 2738
Another point: You shouldn't have concave collision polygons. This is a box2d limitation. Detecting collisions between concave shapes is much more costly. Break up concave polygons into multiple polygons.

NerdinaNutshell

  • Posts: 251
Another point: You shouldn't have concave collision polygons. This is a box2d limitation. Detecting collisions between concave shapes is much more costly. Break up concave polygons into multiple polygons.
So is a concave collision shape defined as one that dips into the box surrounding the actor and then out again?
*Puff*

Luyren

  • *
  • Posts: 2810
If a straight line between two points inside the polygon can leave the polygon's area, it's concave.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.