Adding collision component using entity's render asset as the asset at runtime

Hi - I’ve been trying this like so, but it’s not having any of it.

var asset = this.entity.render.asset;

    this.entity.addComponent('rigidbody', {

    type: 'static'

    });

    var collider = this.entity.addComponent('collision', {

            type: 'mesh',

            asset: asset.resource

    });

I was looking at this, although am aware this might now be out of date.

any help much appreciate…

Hi @jerryComo,

For a render asset you need to use the renderAsset property, and also pass the asset object as it is, no need to pass its resource property:

   var collider = this.entity.addComponent('collision', {
            type: 'mesh',
            renderAsset: asset
    });
2 Likes

thanks L - I’ll try that now :slight_smile: