I understand correctly, in order to insert an object into the hand and make it move along with the animation, I have to find a node and addChild an entity to it, like this:
var FindNode = pc.createScript('findNode');
FindNode.attributes.add('prize', {type:'entity'})
// initialize code called once per entity
FindNode.prototype.initialize = function() {
const arm = this.entity.findByPath('RootNode/RigRArm1Gizmo')
const root = this.app.root.findByName('Root')
root.removeChild(this.prize)
arm.addChild(this.prize)
};
It doesn’t work, error :GraphNode is already parented
The reason it does not work in your code is because this.prize is not a child of root. So, when you call root.removeChild(this.prize), nothing happens and when you later try to add this.prize to arm, it gives an error, because it still has a parent.
It should appear at the new location keeping the current local position it had when it was under the previous parent. If it had a local position far away from parent’s center, then it will also be far away from the new parent after you reparent it. You can read the .getLocalPosition() to check if it is correct or reset it to zero. Also make sure the entity is actually enabled after you reparent it.
Yes, it really is. You still need to scale up a lot. And is it possible to translate the scale that the previous parent had to the corresponding scale of the current one?