When using Unity to make 2D Platformers.
- A Box Collider2D can get the rounding advantages of a capsule collider via the edge radius attribute.
- A Tilemap Collider2D will treat each tile as an individual collider unless you check “Used by Composite”, which has performance pitfalls and can get you caught on corners. Adding the requisite composite collider automatically adds a rigidbody, so be sure to set that to static.
- Be sure to set static components (such as large swaths of your map) to static, to enable various optimizations.
- Be sure to set your player character’s collision to Continuous and interpolation to Interpolate so you don’t have to deal with the Bullet problem.
- If you want to use Physics2D.Raycast for sensors, and your plan is to start the raycast inside the character’s collider, be sure to deselect “Queries start in colliders” in the Project Settings.
- Unity doesn’t play nicely with C# events. If you want a public event that multiple entities can subscribe to, look up Unity Events. If you just want one component to broadcast an event to fellow components, it’s easier to just wire them up by hand.