├── Editor.meta
├── Editor
├── RapierEntry.cs
└── RapierEntry.cs.meta
├── README.md
├── README.md.meta
├── Runtime.meta
├── Runtime
├── Components.meta
├── Components
│ ├── RapierConfiguration.cs
│ ├── RapierConfiguration.cs.meta
│ ├── RapierFixedJoint.cs
│ ├── RapierFixedJoint.cs.meta
│ ├── RapierJoint.cs
│ ├── RapierJoint.cs.meta
│ ├── RapierPrismaticJoint.cs
│ ├── RapierPrismaticJoint.cs.meta
│ ├── RapierRevoluteJoint.cs
│ ├── RapierRevoluteJoint.cs.meta
│ ├── RapierSphericalJoint.cs
│ └── RapierSphericalJoint.cs.meta
├── NativeLoader.cs
├── NativeLoader.cs.meta
├── Packages.rapier4unity.Runtime.asmdef
├── Packages.rapier4unity.Runtime.asmdef.meta
├── PhysicsEventWrapper.cs
├── PhysicsEventWrapper.cs.meta
├── RapierBindings.cs
├── RapierBindings.cs.meta
├── RapierBinds.cs
└── RapierBinds.cs.meta
├── Unity.Rapier4Unity.CodeGen.meta
├── Unity.Rapier4Unity.CodeGen
├── ILPPHelpers.cs
├── ILPPHelpers.cs.meta
├── PhysicsPostProcessor.cs
├── PhysicsPostProcessor.cs.meta
├── Unity.Rapier4Unity.CodeGen.asmdef
└── Unity.Rapier4Unity.CodeGen.asmdef.meta
├── build_bin.meta
├── build_bin
├── Android.meta
├── Android
│ ├── librapier_c_bind.so
│ ├── librapier_c_bind.so.meta
│ ├── libunitybridge.so
│ └── libunitybridge.so.meta
├── Windows.meta
├── Windows
│ ├── rapier_c_bind.dll
│ ├── rapier_c_bind.dll.meta
│ ├── rapier_c_bind.pdb
│ ├── rapier_c_bind.pdb.meta
│ ├── unitybridge.dll
│ ├── unitybridge.dll.meta
│ ├── unitybridge.pdb
│ └── unitybridge.pdb.meta
├── iOS.meta
├── iOS
│ ├── librapier_c_bind.a
│ ├── librapier_c_bind.a.meta
│ ├── libunitybridge.a
│ └── libunitybridge.a.meta
├── macOS.meta
└── macOS
│ ├── rapier_c_bind.bundle
│ ├── rapier_c_bind.bundle.meta
│ ├── unitybridge.bundle
│ └── unitybridge.bundle.meta
├── docs~
├── overview.mp4
├── raycast.mp4
└── readme.md
├── package.json
├── package.json.meta
└── source~
└── rapier-c-bind
├── .gitignore
├── .idea
├── .gitignore
├── encodings.xml
├── modules.xml
├── rapier-c-bind.iml
└── vcs.xml
├── Cargo.toml
├── android_linker.ld
├── build-debug.bat
├── build-debug.sh
├── build-release.bat
├── build-release.sh
├── export-to-unity-dynamic-binder
├── Cargo.toml
└── src
│ └── main.rs
├── get-build-dependencies.bat
├── get-build-dependencies.sh
├── rapierbind
├── Cargo.toml
└── src
│ ├── handles.rs
│ ├── lib.rs
│ └── utils.rs
├── readme.md
└── unitybridge
├── Cargo.toml
└── src
└── lib.rs
/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5bdb05de1422482393a4bb22a326f444
3 | timeCreated: 1741914902
--------------------------------------------------------------------------------
/Editor/RapierEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Runtime.InteropServices;
6 | using UnityEditor;
7 | using UnityEngine;
8 | using UnityEngine.LowLevel;
9 |
10 | namespace Editor
11 | {
12 | [InitializeOnLoad]
13 | public static class RapierEntry
14 | {
15 | static RapierEntry()
16 | {
17 | // Check if the override is enabled
18 | if (!EditorPrefs.GetBool("RapierPhysicsOverrideEnabled", true))
19 | return;
20 |
21 | if (GetSelectedPhysicSDKInfoProperty() is {} idProp)
22 | {
23 | // Set the physics backend to 'Rapier' (by setting the id to the null physics backend id)
24 | if (idProp.uintValue != 3737844653)
25 | {
26 | idProp.uintValue = 3737844653;
27 | idProp.serializedObject.ApplyModifiedProperties();
28 | Debug.LogWarning("Physics backend set to 'None' as Rapier is enabled.\nPlease restart the editor for changes to take effect.");
29 | }
30 | }
31 | }
32 |
33 | static IReadOnlyCollection<(string Name, uint Id)> GetPhysicSDKInfos()
34 | {
35 | var returnVal = new List<(string Name, uint Id)>();
36 |
37 | var getIntegrationInfos = typeof(Physics).GetMethods(BindingFlags.NonPublic|BindingFlags.Static).First(m=> m.GetParameters().Length == 2 && m.Name=="GetIntegrationInfos");
38 | var args = new object[] { null, null };
39 | getIntegrationInfos.Invoke(null, args);
40 | var integrationType = Type.GetType("UnityEngine.IntegrationInfo, UnityEngine.PhysicsModule");
41 | var integrationInfos = (IntPtr)args[0];
42 | var integrationCount = (ulong)args[1];
43 | for (var i = 0; i < (int)integrationCount; i++)
44 | {
45 | var integrationInfo = Marshal.PtrToStructure(integrationInfos, integrationType);
46 | var id = integrationType.GetField("Id").GetValue(integrationInfo);
47 | var name = integrationType.GetProperty("Name").GetValue(integrationInfo);
48 | returnVal.Add(((string)name, (uint)id));
49 | integrationInfos += Marshal.SizeOf(integrationType);
50 | }
51 |
52 | return returnVal;
53 | }
54 |
55 | static SerializedProperty GetSelectedPhysicSDKInfoProperty()
56 | {
57 | var found = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/DynamicsManager.asset");
58 | var serializedObject = found is not null ? new SerializedObject(found[0]) : null;
59 | return serializedObject?.FindProperty("m_CurrentBackendId");
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Editor/RapierEntry.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9030555664e5456091892898eeb3c3af
3 | timeCreated: 1741914989
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Rapier for Unity
2 | This package lets you simulate physics in unity using Rapier.
3 |
4 | This is useful for when you want to run physics in non-unity clients for validation.
5 | E.g. Server Authoritive setup with client side prediction. An example of excellent use is running Rapier on a SpaceTimeDB server, and when syncing it with a client also running Rapier.
6 |
7 |
8 |
9 | ## Overview
10 | Quick showcase:
11 |