Creating an entity of type asset programmatically

Just starting with PlayCanvas.
I am using the example ‘Creating entities programmatically’ and trying to change the rendered entity from a box primitive to an asset. I changed only this part of the code (script entity_creator.js) like that, changing the type to asset and giving the asset number of the model template but it fails.
Any suggestions?

// Add a new Model Component and add it to the Entity.
    entity.addComponent("render", {
        type: 'asset',
        asset: 111431946

The asset needs to be a ‘render’ asset. What type is asset ‘111431946’?

Please post a public example project if you can, that will help a lot

Hi yaustar,

I am taking the asset number of the 3d model template
Here is a link to project with asset number 111432542 of the PalmTrees template asset.

That’s of type ‘Template’, not render asset:

In this case, if you want to create one in the scene, you can do this directly from the template asset


I will try that.

It worked!