How to use the @cocos/cannon.Body function in @cocos/cannon

To help you get started, we’ve selected a few @cocos/cannon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cocos-creator / engine / cocos / physics / cannon / cannon-body.ts View on Github external
constructor (options?: ICreateBodyOptions) {
        options = options || {};
        this._name = options.name || '';
        this._body = new CANNON.Body({
            type: ERigidBodyType.DYNAMIC,
        });
        setWrap(this._body, this);

        this._body.sleepSpeedLimit = 0.1; // Body will feel sleepy if speed<1 (speed == norm of velocity)
        this._body.sleepTimeLimit = 1; // Body falls asleep after 1s of sleepiness

        this._onCollidedListener = this._onCollided.bind(this);
    }