platform effector 2d "surface arc" property

Would somebody please paint me a picture of what this does because I can’t seem to decipher the manual’s description of this “surface arc” property.

I must be pretty dense, because there’s nothing else on the web about it.

What I’m wanting is to create is a jumpthrough/one-way sloped platform solution that also works while it’s moving, but I see there are a lot of complex efforts out there with no real universal solution. Could this property be the official Unity team’s answer to the mysterious one-way slope system?

When two objects collide, they have a collision normal which points in a specific direction. If a circle falls onto the top-edge of a box then the collision normal points ‘up’.

There is a gizmo that shows the surface arc when you have the collider(s) selected.

If the collision normal is within this arc then there is a collision and the object does not pass through. If the collision normal is outside of this arc then there isn’t a collision and the object passed through.

If the platform is a box then you see collision normals like so:

  • Touch top then collision normal is ‘up’ (+y)
  • Touch bottom then collision normal is ‘down’ (-y)
  • Touch left then collision normal is ‘left’ (-x)
  • Touch right then collision normal is ‘right’ (+x)
  • Touch corners then collision normal depends on the corner.

So if you had a surface arc of 180 (default), the arc covers collision normals from left through top to right therefore with the default of 180-degree you collide with the left, top, right (and both top-left and top-right corners) but you don’t collide with the bottom or both bottom-left and bottom-right corners.

You might find it easier to experiment with the platform as a CircleCollider2D. In this case, the collision normals are continuous because the circle doesn’t have any edges. I’ve attached an image demonstrating that.

Here’s another example:

Imagine your platform is a box and you only want to collide with the top-edge but not the left, right or bottom edges (or corners). To do this, the surface arcs needs to cover the ‘up’ angle only so set it to 1-degree. If you want to collide with the left/right edges then set it to 180-degree. If you don’t want it to collide at all, set it to 0-degree and if you want it to collide with everything then set it to 360-degree.

Because the surface arc is centered on the LOCAL up, you can rotate your platform and the rules above still apply.

5 Likes

That is quite ingenious. I must say, this solution gives me mucho respect for the Unity team! Kudos to you guys! :slight_smile:

1 Like