Turn Prefab visible after colliding with an invisible object.,How to turn a prefab visible after collision with an invisible object?

I’m working in a proyect where i want a prefab to become visible after it has collide with an invisible object i have set at certain position in the screen. My problem is that is only seems to work with the latest copy of the prefab that i set, and the copies before that one no longer work. my prefab is a platform with the tag “Floor”, the sprite renderer = false and a force going to the left, when it collides with my game object it turns the sprite renderer = true. and im using this code for my trigger gameobject

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Trigger : MonoBehaviour {

// Use this for initialization
void Start () {
	
}

// Update is called once per frame
void Update () {
	
}

void OnTriggerEnter2D(Collider2D col){

	if (col.tag == "Floor") {
		GameObject.FindGameObjectWithTag ("Floor").GetComponent<SpriteRenderer> ().enabled = true;
	}

}

}`

,I’m working on a proyect where i want a platform to become visible in a certain position in the screen, i have set an invisible object with this script in the position where i want the platforms to become visible.
I have a prefab with the tag “Floor” and a force going to the left, so when it collides with my object the sprite renderer becomes true, the code seems to work properly on the first copy of the prefab i set, but not on the other copies of it. I don’t really know what the problem is. pls help.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Trigger : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}

	void OnTriggerEnter2D(Collider2D col){

		if (col.tag == "Floor") {
			GameObject.FindGameObjectWithTag ("Floor").GetComponent<SpriteRenderer> ().enabled = true;
		}
	
	}

}

You are calling FindGameObjectWithTag to get the object. That will find one object, not necessarily the one that hit your trigger.

I assume you want to effect only the one that hit the trigger. To do that, try changing the following line,

GameObject.FindGameObjectWithTag ("Floor").GetComponent<SpriteRenderer> ().enabled = true;

to

col.gameObject.GetComponent<SpriteRenderer>().enabled=true;

That should enable the SpriteRenderer component of the object that hit your trigger.

Hope this helps,
-Larry