[SOLVED] How do I stop entities being transformed with a parent?

I have the children spawning and shooting from the parent, but they move along the parent. I know that it’s because they are parented.


But I tried to do it via the root, but it seemed like the root moves with the bullets making it seem like nothing is moving, but in reality, EVERYTHING is moving. Was curious if there was a better way!

Here is the CODE and the Project link below it.

var CloneTest = pc.createScript('cloneTest');

CloneTest.prototype.update = function(dt) {
    var highSpot = new pc.Vec3(0,3,0);
    
    for(i = 1; i < this.entity.children.length; i++) {
        var child = this.entity.children[i];
        this.entity.children[i].translateLocal(0,dt*25,0);
    }
    
    if(this.app.mouse.wasPressed(pc.MOUSEBUTTON_LEFT)){
        this.spawn();
    }
    
    if(this.app.keyboard.isPressed(pc.KEY_D)){
        this.entity.translateLocal(dt*1,0,0);
    }
    if(this.app.keyboard.isPressed(pc.KEY_A)){
        this.entity.translateLocal(dt*-1,0,0);
    }
    
};

CloneTest.prototype.spawn = function(){
    
    var entity = new pc.Entity();
    var timer = 0;
    entity.addComponent("model",{type:'box'});
    entity.setLocalPosition(0,1,0);
    this.entity.addChild(entity);

};

https://playcanvas.com/project/482038/overview/testing-grounds

Solved it>>

var CloneTest2 = pc.createScript('cloneTest2');
CloneTest2.attributes.add('testObject',{type:'entity'});

CloneTest2.prototype.initialize = function() {
    this.entities = [];
};

// update code called every frame
CloneTest2.prototype.update = function(dt) {
    
    for(i=0;i<this.entities.length;i++){
        this.entities[i].translateLocal(0,dt*1,0);
    }
    if(this.app.keyboard.wasPressed(pc.KEY_1)){
        this.cloning();
    }
};

CloneTest2.prototype.cloning = function() {
    var spawnSpot = this.entity.getPosition();
    var test = this.testObject.clone();
    this.app.root.addChild(test);
    test.setPosition(spawnSpot);
    this.entities.push(test);
    console.log(spawnSpot);
    
};