global_physics_config.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <!DOCTYPE html>
  2. <html class="writer-html5" lang="en" >
  3. <head>
  4. <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
  5. <meta property="article:modified_time" content="2026-02-20T16:57:51+00:00" /><meta property="og:title" content="Global Physics Config" />
  6. <meta property="og:type" content="website" />
  7. <meta property="og:url" content="https://docs.crownengine.org/html/latest/physics/global_physics_config.html" />
  8. <meta property="og:site_name" content="Crown 0.62.0 Manual" />
  9. <meta property="og:description" content="The global.physics_config resource defines physics materials, collision filters, and actor classes used by Crown’s physics simulation. The file is stored in SJSON format and must be edited manually. Example: Materials: Physics materials define surface response parameters for a..." />
  10. <meta name="description" content="The global.physics_config resource defines physics materials, collision filters, and actor classes used by Crown’s physics simulation. The file is stored in SJSON format and must be edited manually. Example: Materials: Physics materials define surface response parameters for a..." />
  11. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  12. <title>Global Physics Config &mdash; Crown 0.62.0 Manual 0.62.0 documentation</title>
  13. <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  14. <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  15. <link rel="stylesheet" href="../_static/css/custom.css" type="text/css" />
  16. <link rel="shortcut icon" href="../_static/org.crownengine.Crown.svg"/>
  17. <link rel="canonical" href="https://docs.crownengine.org/html/latest/physics/global_physics_config.html" />
  18. <!--[if lt IE 9]>
  19. <script src="../_static/js/html5shiv.min.js"></script>
  20. <![endif]-->
  21. <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
  22. <script src="../_static/jquery.js"></script>
  23. <script src="../_static/underscore.js"></script>
  24. <script src="../_static/doctools.js"></script>
  25. <script src="../_static/js/theme.js"></script>
  26. <link rel="index" title="Index" href="../genindex.html" />
  27. <link rel="search" title="Search" href="../search.html" />
  28. <link rel="copyright" title="Copyright" href="../copyright.html" />
  29. <link rel="next" title="Writing Gameplay" href="../gameplay/index.html" />
  30. <link rel="prev" title="Rigid Bodies" href="rigid_bodies.html" />
  31. </head>
  32. <body class="wy-body-for-nav">
  33. <div class="wy-grid-for-nav">
  34. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  35. <div class="wy-side-scroll">
  36. <div class="wy-side-nav-search" >
  37. <a href="../index.html">
  38. <img src="../_static/org.crownengine.Crown.svg" class="logo" alt="Logo"/>
  39. </a>
  40. <div class="version">
  41. Crown 0.62.0 Manual
  42. </div>
  43. <div role="search">
  44. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  45. <input type="text" name="q" placeholder="Search docs" />
  46. <input type="hidden" name="check_keywords" value="yes" />
  47. <input type="hidden" name="area" value="default" />
  48. </form>
  49. </div>
  50. </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
  51. <ul class="current">
  52. <li class="toctree-l1"><a class="reference internal" href="../changelog.html">Changelog</a></li>
  53. <li class="toctree-l1"><a class="reference internal" href="../introduction.html">Introduction</a></li>
  54. <li class="toctree-l1"><a class="reference internal" href="../installing_crown/index.html">Installing Crown</a></li>
  55. <li class="toctree-l1"><a class="reference internal" href="../getting_started/index.html">Getting Started</a></li>
  56. <li class="toctree-l1"><a class="reference internal" href="../level_editor/index.html">Level Editor</a></li>
  57. <li class="toctree-l1"><a class="reference internal" href="../importing_resources/index.html">Importing Resources</a></li>
  58. <li class="toctree-l1"><a class="reference internal" href="../units/index.html">Units</a></li>
  59. <li class="toctree-l1"><a class="reference internal" href="../rendering/index.html">Rendering</a></li>
  60. <li class="toctree-l1 current"><a class="reference internal" href="index.html">Physics</a><ul class="current">
  61. <li class="toctree-l2"><a class="reference internal" href="rigid_bodies.html">Rigid Bodies</a></li>
  62. <li class="toctree-l2 current"><a class="current reference internal" href="#">Global Physics Config</a><ul>
  63. <li class="toctree-l3"><a class="reference internal" href="#example">Example</a></li>
  64. <li class="toctree-l3"><a class="reference internal" href="#materials">Materials</a></li>
  65. <li class="toctree-l3"><a class="reference internal" href="#collision-filters">Collision filters</a><ul>
  66. <li class="toctree-l4"><a class="reference internal" href="#collision-rule">Collision rule</a></li>
  67. </ul>
  68. </li>
  69. <li class="toctree-l3"><a class="reference internal" href="#actor-classes">Actor classes</a></li>
  70. </ul>
  71. </li>
  72. </ul>
  73. </li>
  74. <li class="toctree-l1"><a class="reference internal" href="../gameplay/index.html">Writing Gameplay</a></li>
  75. <li class="toctree-l1"><a class="reference internal" href="../deploying/index.html">Deploying</a></li>
  76. <li class="toctree-l1"><a class="reference internal" href="../reference/index.html">Reference</a></li>
  77. <li class="toctree-l1"><a class="reference internal" href="../lua_api.html">Lua API reference</a></li>
  78. <li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
  79. <li class="toctree-l1"><a class="reference internal" href="../copyright.html">License</a></li>
  80. <li class="toctree-l1"><a class="reference internal" href="../hackers/index.html">Engine Hackers</a></li>
  81. </ul>
  82. </div>
  83. </div>
  84. </nav>
  85. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
  86. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  87. <a href="../index.html">Crown 0.62.0 Manual</a>
  88. </nav>
  89. <div class="wy-nav-content">
  90. <div class="rst-content">
  91. <div role="navigation" aria-label="Page navigation">
  92. <ul class="wy-breadcrumbs">
  93. <li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
  94. <li><a href="index.html">Physics</a> &raquo;</li>
  95. <li>Global Physics Config</li>
  96. <li class="wy-breadcrumbs-aside">
  97. <a href="../_sources/physics/global_physics_config.rst.txt" rel="nofollow"> View page source</a>
  98. </li>
  99. </ul>
  100. <hr/>
  101. </div>
  102. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  103. <div itemprop="articleBody">
  104. <section id="global-physics-config">
  105. <h1>Global Physics Config<a class="headerlink" href="#global-physics-config" title="Permalink to this headline">¶</a></h1>
  106. <p>The <code class="docutils literal notranslate"><span class="pre">global.physics_config</span></code> resource defines physics materials, collision
  107. filters, and actor classes used by Crown’s physics simulation. The file is
  108. stored in SJSON format and must be edited manually.</p>
  109. <section id="example">
  110. <h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2>
  111. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">materials</span> <span class="o">=</span> <span class="p">{</span>
  112. <span class="n">default</span> <span class="o">=</span> <span class="p">{</span> <span class="n">friction</span> <span class="o">=</span> <span class="mf">0.8</span> <span class="n">restitution</span> <span class="o">=</span> <span class="mf">0.81</span> <span class="p">}</span>
  113. <span class="p">}</span>
  114. <span class="n">collision_filters</span> <span class="o">=</span> <span class="p">{</span>
  115. <span class="n">no_collision</span> <span class="o">=</span> <span class="p">{</span> <span class="n">collides_with</span> <span class="o">=</span> <span class="p">[]</span> <span class="p">}</span>
  116. <span class="n">default</span> <span class="o">=</span> <span class="p">{</span> <span class="n">collides_with_all_except</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;no_collision&quot;</span> <span class="p">]</span> <span class="p">}</span>
  117. <span class="p">}</span>
  118. <span class="n">actors</span> <span class="o">=</span> <span class="p">{</span>
  119. <span class="n">static</span> <span class="o">=</span> <span class="p">{</span> <span class="n">dynamic</span> <span class="o">=</span> <span class="n">false</span> <span class="p">}</span>
  120. <span class="n">dynamic</span> <span class="o">=</span> <span class="p">{</span> <span class="n">dynamic</span> <span class="o">=</span> <span class="n">true</span> <span class="p">}</span>
  121. <span class="n">keyframed</span> <span class="o">=</span> <span class="p">{</span> <span class="n">dynamic</span> <span class="o">=</span> <span class="n">true</span> <span class="n">kinematic</span> <span class="o">=</span> <span class="n">true</span> <span class="n">disable_gravity</span> <span class="o">=</span> <span class="n">true</span> <span class="p">}</span>
  122. <span class="n">trigger</span> <span class="o">=</span> <span class="p">{</span> <span class="n">trigger</span> <span class="o">=</span> <span class="n">true</span> <span class="p">}</span>
  123. <span class="p">}</span>
  124. </pre></div>
  125. </div>
  126. </section>
  127. <section id="materials">
  128. <span id="physics-materials"></span><h2>Materials<a class="headerlink" href="#materials" title="Permalink to this headline">¶</a></h2>
  129. <p>Physics materials define surface response parameters for <a class="reference internal" href="rigid_bodies.html#actors"><span class="std std-ref">actors</span></a>. Create a new material by adding an entry to the <code class="docutils literal notranslate"><span class="pre">materials</span></code>
  130. object:</p>
  131. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">materials</span> <span class="o">=</span> <span class="p">{</span>
  132. <span class="n">default</span> <span class="o">=</span> <span class="o">...</span>
  133. <span class="n">slippery</span> <span class="o">=</span> <span class="p">{</span> <span class="n">friction</span> <span class="o">=</span> <span class="mf">0.1</span> <span class="p">}</span>
  134. <span class="p">}</span>
  135. </pre></div>
  136. </div>
  137. <p>Common material properties:</p>
  138. <ul class="simple">
  139. <li><p><code class="docutils literal notranslate"><span class="pre">friction</span></code>: general contact friction; larger values increase resistance to
  140. sliding.</p></li>
  141. <li><p><code class="docutils literal notranslate"><span class="pre">rolling_friction</span></code>: torsional friction orthogonal to the contact normal;
  142. helps stop spheres rolling forever.</p></li>
  143. <li><p><code class="docutils literal notranslate"><span class="pre">spinning_friction</span></code>: torsional friction around the contact normal; useful
  144. for grasping.</p></li>
  145. <li><p><code class="docutils literal notranslate"><span class="pre">restitution</span></code>: coefficient of restitution; 1 = perfectly elastic
  146. collision, &lt; 1 = inelastic.</p></li>
  147. </ul>
  148. </section>
  149. <section id="collision-filters">
  150. <h2>Collision filters<a class="headerlink" href="#collision-filters" title="Permalink to this headline">¶</a></h2>
  151. <p>Collision filters control which <a class="reference internal" href="rigid_bodies.html#actors"><span class="std std-ref">actors</span></a> interact with which. Define a
  152. filter by adding an entry to the <code class="docutils literal notranslate"><span class="pre">collision_filters</span></code> object:</p>
  153. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">collision_filters</span> <span class="o">=</span> <span class="p">{</span>
  154. <span class="o">...</span>
  155. <span class="n">wall</span> <span class="o">=</span> <span class="p">{}</span>
  156. <span class="n">player</span> <span class="o">=</span> <span class="p">{</span> <span class="n">collides_with</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">&quot;wall&quot;</span> <span class="p">]</span> <span class="p">}</span>
  157. <span class="p">}</span>
  158. </pre></div>
  159. </div>
  160. <p>The filter name (for example <code class="docutils literal notranslate"><span class="pre">player</span></code>) can then be assigned to actors. Use
  161. <code class="docutils literal notranslate"><span class="pre">collides_with</span></code> to list specific filters this filter should collide with,
  162. or <code class="docutils literal notranslate"><span class="pre">collides_with_all_except</span></code> to collide with everything except the
  163. specified filters.</p>
  164. <section id="collision-rule">
  165. <h3>Collision rule<a class="headerlink" href="#collision-rule" title="Permalink to this headline">¶</a></h3>
  166. <p>Two actors A and B generate collisions if either of the following is true:</p>
  167. <ul class="simple">
  168. <li><p>A’s filter has B in its <code class="docutils literal notranslate"><span class="pre">collides_with</span></code> set, or</p></li>
  169. <li><p>B’s filter has A in its <code class="docutils literal notranslate"><span class="pre">collides_with</span></code> set.</p></li>
  170. </ul>
  171. </section>
  172. </section>
  173. <section id="actor-classes">
  174. <h2>Actor classes<a class="headerlink" href="#actor-classes" title="Permalink to this headline">¶</a></h2>
  175. <p>Actor classes are used to specify simulation properties to apply
  176. to <a class="reference internal" href="rigid_bodies.html#actors"><span class="std std-ref">Actors</span></a>. Define classes inside the <code class="docutils literal notranslate"><span class="pre">actors</span></code> object:</p>
  177. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">actors</span> <span class="o">=</span> <span class="p">{</span>
  178. <span class="n">static</span> <span class="o">=</span> <span class="p">{</span> <span class="n">dynamic</span> <span class="o">=</span> <span class="n">false</span> <span class="p">}</span>
  179. <span class="n">dynamic</span> <span class="o">=</span> <span class="p">{</span> <span class="n">dynamic</span> <span class="o">=</span> <span class="n">true</span> <span class="p">}</span>
  180. <span class="n">keyframed</span> <span class="o">=</span> <span class="p">{</span> <span class="n">dynamic</span> <span class="o">=</span> <span class="n">true</span> <span class="n">kinematic</span> <span class="o">=</span> <span class="n">true</span> <span class="n">disable_gravity</span> <span class="o">=</span> <span class="n">true</span> <span class="p">}</span>
  181. <span class="n">trigger</span> <span class="o">=</span> <span class="p">{</span> <span class="n">trigger</span> <span class="o">=</span> <span class="n">true</span> <span class="p">}</span>
  182. <span class="p">}</span>
  183. </pre></div>
  184. </div>
  185. <p>Common actor class properties:</p>
  186. <ul class="simple">
  187. <li><p><code class="docutils literal notranslate"><span class="pre">linear_damping</span></code>: resistance applied to linear motion; useful to slow down
  188. objects unaffected by friction.</p></li>
  189. <li><p><code class="docutils literal notranslate"><span class="pre">angular_damping</span></code>: resistance applied to angular motion.</p></li>
  190. <li><p><code class="docutils literal notranslate"><span class="pre">dynamic</span></code>: when true, the actor is simulated each frame by the physics
  191. engine. If false, the actor cannot move but just collide.</p></li>
  192. <li><p><code class="docutils literal notranslate"><span class="pre">kinematic</span></code>: when true, the actor is driven externally (animation or code)
  193. rather than by physics. Kinematic objects push dynamic objects away but are
  194. unaffected by them.</p></li>
  195. <li><p><code class="docutils literal notranslate"><span class="pre">disable_gravity</span></code>: disables gravity for the actor.</p></li>
  196. <li><p><code class="docutils literal notranslate"><span class="pre">trigger</span></code>: actor does not produce collision responses but still generates
  197. overlap events.</p></li>
  198. </ul>
  199. </section>
  200. </section>
  201. </div>
  202. </div>
  203. <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
  204. <a href="rigid_bodies.html" class="btn btn-neutral float-left" title="Rigid Bodies" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
  205. <a href="../gameplay/index.html" class="btn btn-neutral float-right" title="Writing Gameplay" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
  206. </div>
  207. <hr/>
  208. <div role="contentinfo">
  209. <p>&#169; <a href="../copyright.html">Copyright</a> Except where otherwise noted, content on this page is licensed under a CC-BY-SA 4.0 Int. License.
  210. <span class="lastupdated">Last updated on Feb 20, 2026.
  211. </span></p>
  212. </div>
  213. Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
  214. <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
  215. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  216. </footer>
  217. </div>
  218. </div>
  219. </section>
  220. </div>
  221. <script>
  222. jQuery(function () {
  223. SphinxRtdTheme.Navigation.enable(true);
  224. });
  225. </script>
  226. <!-- Theme Analytics -->
  227. <script async src="https://www.googletagmanager.com/gtag/js?id=G-XNVGCMNDZH"></script>
  228. <script>
  229. window.dataLayer = window.dataLayer || [];
  230. function gtag(){dataLayer.push(arguments);}
  231. gtag('js', new Date());
  232. gtag('config', 'G-XNVGCMNDZH', {
  233. 'anonymize_ip': true,
  234. });
  235. </script>
  236. </body>
  237. </html>