Hello, i have an entity with different models like this
Enemy
—Orc
—Goblin
—skeleton
usually they are random generated, but i need to spawn a specific one so i have a variable “enemy” to call the goblin, how do i disable all the other ones? because
this.enemy.findByName(enemy).enabled=true; // to anable the chosen one
and??? lost in this
Several ways of approach:
- Do they all need to be enabled by default?
- There is a property on pc.Entity called children which has all the child entities: http://developer.playcanvas.com/en/api/pc.Entity.html#children
- Do you need all the models to under the same entity? Could you not have separate entities for each type of enemy?
Thanks @steven i was just rethinking and rewriting the enemy.js script, i think the unique entity will not be useful till the end of the project coz i need different animations for different kind of enemies but for this initial phase is good enough. Unluckly i lost some of the work i did in the past an the models so i have to redo the animations and some model as well. But after years i lost my touch with 3ds a 3d artist woul speed up the process greatly. I also need to work on the frame rate that slow down when player enter the dungeon. Hope someone in future will join me and help coding too
You can use Tags, and findByTag entities and change their state all together.
…right…the same with the level change … so stupid…thanks @max