RapierColliderTweaks.re.ts 738 B

1234567891011121314151617181920212223242526272829303132333435
  1. import RapierBody from '@RE/RogueEngine/rogue-rapier/Components/RapierBody.re';
  2. import * as RE from 'rogue-engine';
  3. export default class RapierColliderTweaks extends RE.Component {
  4. body:RapierBody
  5. @RE.props.num() friction: number = 0
  6. awake() {
  7. this.object3d.traverse(obj => {
  8. const components = RE.getObjectComponents(obj);
  9. components.forEach(comp => {
  10. if (comp instanceof RapierBody) {
  11. this.body = comp
  12. }
  13. });
  14. });
  15. const numColliders = this.body.body.numColliders()
  16. for(let i = 0; i < numColliders; i ++) {
  17. this.body.body.collider(i).setFriction(this.friction)
  18. }
  19. }
  20. start() {
  21. }
  22. update() {
  23. }
  24. }
  25. RE.registerComponent(RapierColliderTweaks);