Hello, in my code I clone the enemy entity but I have a problem with the material used for the health bar https://playcanvas.com/editor/code/352037/health.js this is the script of health bar, the material used as attribute must be unique for each health bar so it gives me an error while I clone the same entity multiple times, how can I solve this??
Edit: maybe something like this?
var Material = app.root.findByName('enemy').script.remainingMaterial;
var newMaterial[i] = Material.clone();
Sorry but i’m struck i have variable ID inside enemy script different for each enemy, when i click on enemy i need to find the enemy with the right ID to: get position and assign damages… i’m lost in code. I get the id when i click on enemy, and after? How do i pick the enemy with that id, get that entity and use the values inside the enemy script?