1"use strict";(self.webpackChunkrapier=self.webpackChunkrapier||[]).push([[2974],{3174:(e,r,t)=>{t.r(r),t.d(r,{assets:()=>o,contentTitle:()=>i,default:()=>d,frontMatter:()=>s,metadata:()=>l,toc:()=>u});var a=t(4848),n=t(8453);t(1470),t(9365);const s={},i=void 0,l={id:"user_guides/templates/rigid_body_damping",title:"rigid_body_damping",description:"Damping lets you slow down a rigid-body automatically. This can be used to achieve a wide variety of effects like",source:"@site/docs/user_guides/templates/rigid_body_damping.mdx",sourceDirName:"user_guides/templates",slug:"/user_guides/templates/rigid_body_damping",permalink:"/docs/user_guides/templates/rigid_body_damping",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{}},o={},u=[];function c(e){const r={code:"code",p:"p",pre:"pre",strong:"strong",...(0,n.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(r.p,{children:["Damping lets you slow down a rigid-body automatically. This can be used to achieve a wide variety of effects like\nfake air friction. Each rigid-body is given a ",(0,a.jsx)(r.strong,{children:"linear damping coefficient"})," (affecting its linear velocity) and an\n",(0,a.jsx)(r.strong,{children:"angular damping coefficient"})," (affecting its angular velocity). Larger values of the damping coefficients lead to\na stronger slow-downs. Their default values are ",(0,a.jsx)(r.code,{children:"0.0"})," (no damping at all)."]}),"\n",(0,a.jsx)(r.p,{children:"This damping coefficients can be set when the rigid-body is created or after its creation:"}),"\n",(0,a.jsxs)("rapier",{children:[(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-rust",children:"<load path='/2d/rust/examples/rs_rigid_bodies2.rs' marker='Damping1' />\n"})}),(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-rust",children:"<load path='/2d/rust/examples/rs_rigid_bodies2.rs' marker='Damping2' />\n"})})]}),"\n",(0,a.jsxs)("bevy",{children:[(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-rust",children:"<load path='/2d/bevy/examples/rigid_bodies_continued2.rs' marker='Damping1' />\n"})}),(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-rust",children:"<load path='/2d/bevy/examples/rigid_bodies_continued2.rs' marker='Damping2' />\n"})})]}),"\n",(0,a.jsxs)("js",{children:[(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-js",children:"<load path='/2d/javascript/src/snippets/rigid_bodies.ts' marker='Damping1' />\n"})}),(0,a.jsx)(r.pre,{children:(0,a.jsx)(r.code,{className:"language-js",children:"<load path='/2d/javascript/src/snippets/rigid_bodies.ts' marker='Damping2' />\n"})})]})]})}function d(e={}){const{wrapper:r}={...(0,n.R)(),...e.components};return r?(0,a.jsx)(r,{...e,children:(0,a.jsx)(c,{...e})}):c(e)}},9365:(e,r,t)=>{t.d(r,{A:()=>i});t(6540);var a=t(8215);const n={tabItem:"tabItem_Ymn6"};var s=t(4848);function i(e){let{children:r,hidden:t,className:i}=e;return(0,s.jsx)("div",{role:"tabpanel",className:(0,a.A)(n.tabItem,i),hidden:t,children:r})}},1470:(e,r,t)=>{t.d(r,{A:()=>_});var a=t(6540),n=t(8215),s=t(3104),i=t(6347),l=t(205),o=t(7485),u=t(1682),c=t(679);function d(e){return a.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,a.isValidElement)(e)&&function(e){const{props:r}=e;return!!r&&"object"==typeof r&&"value"in r}(e))return e;throw new Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function p(e){const{values:r,children:t}=e;return(0,a.useMemo)((()=>{const e=r??function(e){return d(e).map((e=>{let{props:{value:r,label:t,attributes:a,default:n}}=e;return{value:r,label:t,attributes:a,default:n}}))}(t);return function(e){const r=(0,u.XI)(e,((e,r)=>e.value===r.value));if(r.length>0)throw new Error(`Docusaurus error: Duplicate values "${r.map((e=>e.value)).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e}),[r,t])}function m(e){let{value:r,tabValues:t}=e;return t.some((e=>e.value===r))}function f(e){let{queryString:r=!1,groupId:t}=e;const n=(0,i.W6)(),s=function(e){let{queryString:r=!1,groupId:t}=e;if("string"==typeof r)return r;if(!1===r)return null;if(!0===r&&!t)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return t??null}({queryString:r,groupId:t});return[(0,o.aZ)(s),(0,a.useCallback)((e=>{if(!s)return;
1const r=new URLSearchParams(n.location.search);r.set(s,e),n.replace({...n.location,search:r.toString()})}),[s,n])]}function g(e){const{defaultValue:r,queryString:t=!1,groupId:n}=e,s=p(e),[i,o]=(0,a.useState)((()=>function(e){let{defaultValue:r,tabValues:t}=e;if(0===t.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(r){if(!m({value:r,tabValues:t}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${r}" but none of its children has the corresponding value. Available values are: ${t.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return r}const a=t.find((e=>e.default))??t[0];if(!a)throw new Error("Unexpected error: 0 tabValues");return a.value}({defaultValue:r,tabValues:s}))),[u,d]=f({queryString:t,groupId:n}),[g,h]=function(e){let{groupId:r}=e;const t=function(e){return e?`docusaurus.tab.${e}`:null}(r),[n,s]=(0,c.Dv)(t);return[n,(0,a.useCallback)((e=>{t&&s.set(e)}),[t,s])]}({groupId:n}),b=(()=>{const e=u??g;return m({value:e,tabValues:s})?e:null})();(0,l.A)((()=>{b&&o(b)}),[b]);return{selectedValue:i,selectValue:(0,a.useCallback)((e=>{if(!m({value:e,tabValues:s}))throw new Error(`Can't select invalid tab value=${e}`);o(e),d(e),h(e)}),[d,h,s]),tabValues:s}}var h=t(2303);const b={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var v=t(4848);function x(e){let{className:r,block:t,selectedValue:a,selectValue:i,tabValues:l}=e;const o=[],{blockElementScrollPositionUntilNextRender:u}=(0,s.a_)(),c=e=>{const r=e.currentTarget,t=o.indexOf(r),n=l[t].value;n!==a&&(u(r),i(n))},d=e=>{let r=null;switch(e.key){case"Enter":c(e);break;case"ArrowRight":{const t=o.indexOf(e.currentTarget)+1;r=o[t]??o[0];break}case"ArrowLeft":{const t=o.indexOf(e.currentTarget)-1;r=o[t]??o[o.length-1];break}}r?.focus()};return(0,v.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,n.A)("tabs",{"tabs--block":t},r),children:l.map((e=>{let{value:r,label:t,attributes:s}=e;return(0,v.jsx)("li",{role:"tab",tabIndex:a===r?0:-1,"aria-selected":a===r,ref:e=>o.push(e),onKeyDown:d,onClick:c,...s,className:(0,n.A)("tabs__item",b.tabItem,s?.className,{"tabs__item--active":a===r}),children:t??r},r)}))})}function y(e){let{lazy:r,children:t,selectedValue:s}=e;const i=(Array.isArray(t)?t:[t]).filter(Boolean);if(r){const e=i.find((e=>e.props.value===s));return e?(0,a.cloneElement)(e,{className:(0,n.A)("margin-top--md",e.props.className)}):null}return(0,v.jsx)("div",{className:"margin-top--md",children:i.map(((e,r)=>(0,a.cloneElement)(e,{key:r,hidden:e.props.value!==s})))})}function j(e){const r=g(e);return(0,v.jsxs)("div",{className:(0,n.A)("tabs-container",b.tabList),children:[(0,v.jsx)(x,{...r,...e}),(0,v.jsx)(y,{...r,...e})]})}function _(e){const r=(0,h.A)();return(0,v.jsx)(j,{...e,children:d(e.children)},String(r))}},8453:(e,r,t)=>{t.d(r,{R:()=>i,x:()=>l});var a=t(6540);const n={},s=a.createContext(n);function i(e){const r=a.useContext(s);return a.useMemo((function(){return"function"==typeof e?e(r):{...r,...e}}),[r,e])}function l(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:i(e.components),a.createElement(s.Provider,{value:r},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.