transform.localScale affects all instances at once

Hi all, I am trying to make a very simple game similar to the iOS title Circle Stop.
I am quite new at coding so even that is difficult for me :frowning:
I have a player moving automatically and several pickups on his path. All pickups are instances of the same prefab.

When the player is hitting one pickup, I want that pickup to scale up. I am using the code below.
I have a script on the player to detect collisions (ColCheck). I have a script on the pickup to transform its scale.
basically, the pickup script checks if the collision happened and scales the object.

function Update () {  
		if (hintCheck == ColCheck.pickupHit) {
			transform.localScale = Vector2(2, 2);
		}
	}

the variables hintCheck and pickupHit allow me to see how many pickups were hit. Each pickup has a different value. The first has hintCheck = 1, the second hintCheck = 2 and so on… This way, each pickup should react independently.

As soon as the player hits the first pickup, all are scaled. This really surprised me as I used before transform.position and that only affected one pickup at a time.

Anybody knows what I am doing wrong?

You have this script on every instance and so when hintCheck == pickUpHit they will all scale. Each of these objects is checking this condition every update.

Try dettaching the objects from the Prefabs. Go to the Hierarchy and select the object. Then in the GameObject menu, click “Break Prefab Instance”.
The problem with this is that any change you make to the prefab is no longer valid for these instances. You can solve that by creating instances on code through the GameObject.Instantiate function.