i want get random object from array and make a clone of it but the clone functionality is not working fine, i’m new in playcanvas, so can anyone help me.
this.PuzzleArray = this.app.root.findByTag("Shapes");
console.log("PuzzleArray Length",this.PuzzleArray.length);
// this.RandomPuzzle = this.PuzzleArray[Math.floor(Math.random(this.PuzzleArray.length - 1))];
// console.log("RandomPuzzle" + this.RandomPuzzle.name);
var RandomPuzzle = 0.2;
RandomPuzzle = Math.random() * this.PuzzleArray.length;
this.puzzle = this.PuzzleArray[Math.floor(RandomPuzzle)];
console.log("RandomPuzzle",this.puzzle.name);
var posX=this.Point1.getLocalPosition().x;
var posY=this.Point1.getLocalPosition().y;
var posZ=this.Point1.getLocalPosition().z;
var cloneholder = this.puzzle.clone();
cloneholder.enabled=true;
cloneholder.setPosition(posX,posY,posZ);
this.Point1.addChild(cloneholder);
console.log("working");
var RandomPuzzle1 = Math.random() * this.PuzzleArray.length;
this.puzzle = this.PuzzleArray[Math.floor(RandomPuzzle1)];
};