[SOLVED] Error reassigning asset variable

I have an asset and I am trying to programmatically create a new_asset on top of that asset and then assign new_asset to asset so that I can run the same code again and again to create assets on top of one another. But for some reason I can’t assign the new_asset to the asset variable.

NewAsset.translate(0,Asset.getLocalPosition().x + 1, 0);
Asset = NewAsset;
console.log(Asset.getLocalPosition().x);

My first Asset is at x=0. So the first time the code runs a NewAsset is created at x=1 and the console should print 1 but it prints 0. Every time the code runs a NewAsset keeps getting created at x=1.

Just to check, do you mean pc.Entity or do you really mean a pc.Asset?

Edit:

If these are really Entities, assuming that NewAsset starts at 0, 0, 0

NewAsset.translate(0,Asset.getLocalPosition().x + 1, 0);

This is moving it on the Y axis. After this, NewAsset is at 0,1,0

Asset = NewAsset;
console.log(Asset.getLocalPosition().x);

And as you are getting the X component of the Entity here, it still be 0.

1 Like

Once again I can’t thank you enough. I can’t believe how stupid I am.