[SOLVED] Creating new entity in initialization

Hello I’m trying to create some container entities to store sub-entities. Right now it is giving me

launch.js:8025 TypeError: this.tileContainer.setLocalPosition is not a function

// initialize code called once per entity
Board.prototype.initialize = function() {
    this.tileContainer = pc.Entity("Tiles");
    this.tileContainer.setLocalPosition(0, 0, -1);

    // omitted for clarity

Is it not possible to create new entities in initialize function? or did I messed something else?

Hi @SiyahaS,

It’s definitely possible, you are just missing the JS new keyword, to instantiate an instance of the pc.Entity class:

this.tileContainer = new pc.Entity("Tiles");

The rest should work fine.