0
\$\begingroup\$

I am working on a robotics simulation application in Unity. I want to replace the default physics engine, PhysX, with Mujoco. My goal is to enable a toggle within the Unity application to switch between using PhysX and Mujoco. Mujoco provides better realism for certain scenarios, but I also want to leverage Unity's default capabilities for simpler tasks.

Currently, I am new to Unity and have limited experience, so I would appreciate guidance on the following:

  1. How can I integrate Mujoco so that I can use it instead of PhysX, in a way that still lets me switch back to PhysX when needed?

  2. Do I need to duplicate assets, scenes, or environments to implement both physics engines, or is there a more efficient approach?

\$\endgroup\$
1

2 Answers 2

1
\$\begingroup\$

MuJoCo uses its own components with their own data that have nothing to do with their analogs from the Unity standard physics engine. So switching back and forth between them is anything but trivial.

You probably would need to:

  1. Add both the Unity and the MuJoCo components to objects
  2. Add another script that allows to switch between them by enabling one set of components, disabling the other and copying the current state from the disabled to the enabeld components (as far as that's possible).
\$\endgroup\$
1
  • 1
    \$\begingroup\$ It might make sense to make a wrapper class for the Unity Physics / Phys X components and another for the MuJoCo components, implementing a common interface. Then all your gameplay scripts can communicate with this interface, and the wrapper classes will handle translating the call into the corresponding equivalent for the concrete implementation currently in use. \$\endgroup\$
    – LudoProf
    Commented Nov 28, 2024 at 13:14
0
\$\begingroup\$

Simple answer is that you can't replace the PhysX implementation in Unity.

You can however implement your own physics and create components that you place on the game objects that control their movement and behavior.

Those custom components would work to provide input/output from your physics implementation.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.