[TS] Help fixing prefab script affecting only latest instance

Hi there,

I am new to Cocos Creator and have been trying to work prefabs out. Basically I instantiate three nodes of a prefab (which has a script) and whenever I trigger an action in any of those prefab nodes, [update] Only the last instance is affected.

Say, if my action is selecting my first instance to remove that node, then somehow only the last instance will be removed, and can no longer interact with the previous instances.

Don’t know if i’m creating my instances wrongly?

const xNode= cc.instantiate(this.xPrefab);
xNode.position = parent.convertToNodeSpaceAR(touch.getLocation())’
parent.addChild(xNode);

Any help would be appreciated!

Thanks!

Found my mistake… In the script of the prefab I was creating a reference in onLoad() node = this.node… so last loaded noad would take all the interactions. Silly mistake, but I guess its a way to learn :slight_smile: