Physics Core 2D in Unity 6.5

Physics Core 2D in Unity 6.5

The Physics Core 2D release in 6000.5.0b2 introduces key updates:

  • Renaming: “LowLevelPhysics2D” is now “PhysicsCore2D,” reflecting its foundational role.
  • Modularity: The new module is independent, allowing the optional, separate Physics2D module to be disabled, reducing memory and build size.
  • Namespace Consistency: The namespace changed from UnityEngine.LowLevelPhysics2D to Unity.U2D.Physics for 2D feature alignment.
  • Enhancements: Feature improvements establish a base for upcoming components to be distributed as a package within the same Unity.U2D.Physics namespace.

Namespace change

Projects from versions 6.3 or 6.4 will automatically migrate to the new namespace upon opening. The underlying types remain unchanged, guaranteeing full backwards compatibility.

For maintaining compatibility with the older namespace in source files, use the following conditional compilation:

#if UNITY_6000_5_OR_NEWER
using Unity.U2D.Physics;
#else
using UnityEngine.LowLevelPhysics2D;
#endif

Dedicated Module

The new Physics Core 2D built-in module, available via the Package Manager, includes new physics features. Disabling the older physics module, if not needed, reduces memory and build size.


New PhysicsCore2D module.

Project Settings

The Physics Core 2D module now has dedicated Project Settings. The asset PhysicsLowLevelSettings2D has been renamed to PhysicsCoreSettings2D to match. This asset updates automatically and is editable directly within the Project Settings after selection in the Project view, offering more space than the Inspector.


Project Settings for editing PhysicsCoreSettings asset

Transforms

This release introduces new Transform Writing options, including callbacks and write/tween events, enabling custom transform writing and tweening. Developers can intercept standard transform writes and redirect them to custom data structures (like ECS components or buffers), with automatic pose and tween calculations available. Automatic writing now offers both parallel and sequential modes to suit different Transform hierarchy structures.


Custom Modes for Transform Writing and Tweenin g

Transform change detection is now fully integrated, offering a configurable callback (ITransformChangedCallback) for any object. This callback provides an event detailing which transforms changed and the reason (translation, rotation, scale, animation, re-parenting) at frame-start, fixed-update, or per-update. Physics component authoring also includes dedicated write methods to update transforms off the main thread without firing change callbacks, preventing re-entrant notifications.


Transform Change Mode optio n s

The Transform Plane mode now offers a new custom option, allowing users to specify an arbitrary 3D transform plane beyond the standard fixed XY, XZ, and ZY options, providing full control over 3D world transform application.


2D physics simulation writing to a custom orientated 3D pl a ne

Contact Filter Mode

The new Contact Filter Mode in PhysicsCore2D allows developers to simplify contact filter setup by choosing whether layer-based contact detection requires mutual agreement between two shapes or if a single shape’s configuration is sufficient. Additionally, a new Contact Filter Group Mode has been added, giving control over the behavior of ContactFilter.groupIndex. The new filter mode changes the previous fixed semantics so that contact is only considered when both Contact Filter instances share the same group Index, after which standard masks apply. This introduces a new, flexible grouping dimension for various custom semantics.


Global Contact Filter Opt i ons

Ignore Filter Options

The new Ignore Filter offers fine-grained control for all world queries (shape/ray casts, overlaps, character movers), supplementing category-based filtering. It allows ignoring criteria like triggers, static geometry, or specific shape types (e.g., circles). Supplied via PhysicsQuery.QueryFilter, it works across all query types without extra setup.

The Ignore Filter also extends to the physics renderer, controlling what is drawn. It can be set per-world via PhysicsWorld.drawFilter or initialized through PhysicsWorldDefinition.drawFilter, and changes are reflected instantly.

Continuous Collision Tuning

Continuous collision detection (CCD) for dynamic bodies, automatically limiting its use to maintain performance. For finer control, a per-body Collision Threshold can be configured. The default of 0.5 triggers CCD for movement of at least half the shape’s extent; setting it to 0 uses CCD for any movement. This improvement will also be added to 6.3 LTS.


Per-body Collision Threshold o p tion

Query Features

Existing overlap and test-overlap queries have been extended to support spans of objects, making it straightforward to perform multiple overlap checks in a single operation.

Ownership

Ownership is a component-authoring feature that assigns objects created by a component an owner and an ownership key. This restricts critical modifications, like object destruction, to the owner, preventing accidental issues. This release allows explicit ownership keys via PhysicsWorld.CreateOwnerKey, applicable to single or multiple objects. This simplifies multi-object management by removing the need for individual object keys. Ownership is supported across PhysicsWorld, PhysicsBody, PhysicsShape, PhysicsChain, and all PhysicsJoint types.

Maximum Worlds

The maximum number of independent, isolated worlds has been significantly increased and is now user-configurable. Previously fixed at 128 (with 127 practically available, as Unity automatically creates one default world), this limit can now be set anywhere between 1 and 1024 via the core settings.

This is particularly beneficial for projects that only need a single default world. Setting the maximum to 1 eliminates the static memory overhead associated with provisioning the full 128 worlds, saving approximately 300KB. For backwards compatibility, the default remains at 128 for now, though it is expected to change to 4 in a future update once the setting has been fully rolled out, reducing the default memory footprint as low as possible.


Global Maximum Worlds o p tion.

Rendering

Physics rendering has been improved. The simple rendering checkbox is replaced by a configurable Rendering Mode covering all player builds.

The drawing API now supports batch drawing for geometry and shapes, crucially adding the ability to directly visualize physics query inputs (arguments) and outputs (results) like ray-casts and shape-casts, removing interpretation ambiguity.

Access to draw data is now available via the requested PhysicsEvents.WorldDrawResults event.

Finally, PhysicsBody, PhysicsShape, and PhysicsJoint now include a World Drawing toggle for per-object rendering control at runtime.


Global Rendering Mode o ption.

--

The update includes numerous other improvements such as better shader performance and pixel accuracy, interpolation syncing, near-complete thread-safety, owner-based custom data, a PhysicsWorldDefinition change event, PhysicsRotate using radians or degrees, and quality-of-life additions for component creation. Many of these features have been back-ported to 6.3 LTS for consistency.

The 2D physics manual has been updated with new info as well.

Useful Links

Scripting Documentation (Unity.U2D.Physics)
PhysicsExamples2D (6000.5 branch)
Development Videos

--

Let’s discuss!

Try out the updates and share your thoughts, questions and comments in the thread. We’d love to know how you’re using it in your projects, and what works well & what needs improving.

31 Likes

Is this the gameobject collider 2d component stuff using the new physics core now or not?

1 Like

No. That won’t happen for the time being. Physics Core 2D remains an isolate low-level API for now.

1 Like

As the post says:

Enhancements: Feature improvements establish a base for upcoming components to be distributed as a package within the same Unity.U2D.Physics namespace.

No, the legacy components aren’t moving to a package and won’t be altered. Trying to update them would break existing projects, especially since they run on a fundamentally different, single-threaded version of Box2D. They’ll keep working exactly as you expect them to. To enforce a clean break between the two systems, they are now completely isolated into separate built-in modules. If you aren’t adopting the new physics just yet, you can simply disable the new module altogether.

When we say “upcoming components” we mean a new package for Unity 6000.7 built from the ground up for the multi-threaded API. Rather than using hidden backend magic, these components just drive the exact same 100% public API you have access to. This makes them completely extensible and ensures your own components will work seamlessly alongside them, which is a huge step up from the “rigidness” (pun intended) of the old physics system.

They’ll be similar to this example/test package albeit with different components and will be fully tested and therefore production ready.

6 Likes

I see, I had previously checked this project out last year but was hoping to see 2d inspector components for it in a more official sense ready to use. You mentioned the test package but it would be pointless to use those now if there are going to change as ‘they’ll be similar’ implying it might still be a mess to change later?

I’ll probably just wait though very much interested in using it, now that alignment doesn’t have to be vertical.

Hard to advise really. Creating a basic component is super easy and the whole point of the test package is to show how easy it can be. The test package is not a placeholder which you upgrade later, it serves as an example of component writing so I’m not quite following what you mean by “it might still be a mess to change later”.

If all you want to use is components we write then 6.7 will be for you and we can leave it at that but the new physics is designed so that you can and should write your own too, to supplement ours and others. You won’t be creating 5000 prefab instances with components to produces 5000 bodies and shapes and have the same batch creation performance you have now with the API although the simulation performance itself will be the same as using the API directly which, of course, is all our 6.7 components will be doing. :slight_smile:

1 Like

Will the 6.7 components get some new abilities compared to the current ones?

Really my main question is if it’s possible to get a full XZ-based setup in 6.7 (or some future point after that) with the same components and the same gizmos, using just built-in components, or if I have to build that myself.

I was going to build that myself earlier to fix an earlier version that uses XY ghost components to drive XZ 2D gameObjects, but I never got the time. Now I’m eyeing waiting for 6.7.

Yes but in the end they’re only exposing what’s already there in the new API. There will be a new asset-based configuration set-up though to reduce micro-management of configuration for lots of components along with base classes that will help you write your own although you can do that now from scratch with minimal code TBH.

Yes as it’s not an optional part of physics, it’s integral to it. XY is not treated as a special, it’s just another world transform writing mode but this is not new, it’s been available since it first came out in 6.3. Those options are in the PhysicsWorldDefinition and have always been available in the project settings.

All new components will adhere to this but they themselves do not control it, the world does so the new components won’t change this. The images above are from the project settings for the default world but now includes new properties for custom transforms.

6.3 : Use 2D physics in 3D space using the LowLevelPhysics2D API

Hope that makes sense but if not, feel free to DM me and I can elaborate further!

It makes sense, yeah. Setting the default Physics World Definition to have the XZ plane seems to be what I’m asking for.

Is there a way to differentiate this on a per-scene basis, at edit time? The thing I’m trying to achieve is:

  • Have some scenes that are XY based 2D
  • Have other scenes that are XZ based 2D
  • Be able to edit the colliders in the correct space in the scene view, outside of play mode. So things like using handles to drag the collider’s size, etc.
  • Hopefully also have that work in prefab mode… somehow?

It seems like currently you can set a global up and then override that at runtime, but not at edit time?

You can have as many PhysicsWorld as you like, it’s just that there’s a default one for convenience. You can have multiple worlds in the same scene. Scenes are not something physics knows about, nor are GameObject.

Have some scenes that are XY based 2D

Yes.

Have other scenes that are XZ based 2D

Yes.

Be able to edit the colliders in the correct space in the scene view, outside of play mode. So things like using handles to drag the collider’s size, etc.

Yes.

Hopefully also have that work in prefab mode… somehow?

Yes.

It seems like currently you can set a global up and then override that at runtime, but not at edit time?

If you’re referring to the default world created then yes but that’s just the default world which most people will use and there’s nothing special about it beyond you not being able to destroy it yourself.

I just recorded this to demonstrate this using the Test package that shipped in 6.3 but here I’m using it in 6.6-alpha and it’s three different worlds, each using the fixed transform planes then me editing them:

It’s basically this scene from about a year ago:

6 Likes

Right! I hadn’t caught that the physics worlds could live in the scene as components. That makes a lot of sense.

I assume that’ll be shipped in some form in 6.7?

1 Like

Yes so I’ll wait for 6.7 then… the ‘Test Body, Test Shapes’ will be getting new component names and stuff what else is planned for that?

Will there be something to do this https://assetstore.unity.com/packages/tools/physics/2d-mesh-collider-206728#description

Something more optimized and updated to work with the new physics for runtime 3d mesh > 2d collision intersected on whatever world plane… would be good a feature to have out the box for this new improvement that makes doing more kinds of 2.5d games really.

Honestly that is actually already doable just a little custom code. Had to do something similar for VFX Graph particles to make them work with the new Physics Core 2D API, also had to write a custom Cinemachine extention for a custom PhysicsShape CameraConfiner2D. Please note the following way was my first attempt. It can probably be done better honestly.

Basically I take the depth buffer of the drawn objects on scene and filter out the rendered view for objects with collision masks. That collision mask is used to draw PhysicsShape outlines with the PhysicsComposer API. You can do this in an editor to create a PhysicsShape of your scene from the camera view and just bake it.

I made custom components for Physics Core 2D that bakes the PhysicsShape into anything I need. Made custom TilemapShapes, RectangleShapes, SpriteShapes, and DepthBufferShapes (not a monobehavior component for reasons) for vfx graph systems.

Example of a custom PhysicsShape component for Tilemaps.
You can create a lot of stuff easily with it already in 6.3 with really high performance in editor and runtime. Note this one doesn’t use Depth Buffer, but reads the Sprite Physics Outline of the tiles placed via a Tilemap.

If you are using Unity 6.6 found a fun and simple way of just assigning the body.transform to a PhysicsTransform to do all the heavy lifting. Warning before 6.6 you would probably have to look into

PhysicsBody.SetAndWriteTransform(PhysicsTransform);

1 Like

Yes, the new components will include a world component similar to the one in the Test package. :slight_smile:

1 Like

Just a quick clarification: the final product isn’t the Test package with a new coat of paint. Test is just an example and won’t be changing.

It’s still a WIP for 6.7 and things will change so I won’t guarantee certain features but please, continue to ask questions and share your feature requests and I’ll answer what I can and absolutely note things that may not have been considered! Getting your feedback is exactly why this post was created. Either here, a DM or preferably in a new post (tag me in). Discuss!

Now whether we’ll be landing certain extra feature support in 6.7 such as a new component for Tilemap or automatic compositing (etc) is unclear at the moment. With that said @Jonathan-Westfall-8Bits has been instrumental in showing how you can do that kind of thing yourself right now and we landed stuff in 6.4 to help with this such as grabbing tile/sprite data without C# allocations.

Also, I’ve been dropping example code and components into the Snippets project. That way, I can share this kind of stuff without bloating the list of components we have to officially support. If you’re working with the API now then I can add demonstrations there (time allowing).

The whole goal of giving you full access to the core API (the exact same tools we use ourselves) is so that anyone (you, us, and the community) can build whatever custom components they need. If Unity tried to build and maintain a component for every possible use-case (such as Effectors, for instance), we’d end up with a huge, bloated list that would be a real problem to support as things evolve. This new API is designed to avoid that situation by allowing anyone to help themselves. Moving forward, all Unity supplied components will use 100% public API meaning they serve as production code but also examples to roll/modify your own.

As for the mesh manipulation, it actually doesn’t look too tricky and like @Jonathan-Westfall-8Bits pointed out above, you can actually already pull that off right now in 6.3. He’s been very active using this new API with his own components. An interesting point here is that when we land the 6.7 components, they will be able to interact with @Jonathan-Westfall-8Bits components without being designed specifically that way; this is the main advantage here in that it’s not a case of Unity components or your own. :slight_smile:

The Test package gives a pretty good sneak peek of how this all works, but if you’d rather hold off, you can always wait for 6.7 and build your custom components on top of that though. I would urge you, assuming you’ve not already, to jump in and experiment!

2 Likes

ECS baking workflow support please