My Prefab does not display in Game Run just in the Scene!!

Hi guys i have a problem, and i been seraching but i cant find anything, the problem is that i have two instanciated prefabs attach to my main camara, so when i do a certain action on the screen for each of them, it is suppouse to reveal them, for the the one i got problems this is the code, i already attach him from the herachy to the prefab , i think anything is good, but only works in one of my two prefabs for this i , im like a new to unity, i already read the API for several functions but i cannot find and awnser for this, so i hope some one can help me, heres the code.

using UnityEngine;
using System.Collections;

public class blue : MonoBehaviour
{
public GameObject azul;

int counter =0;

// Use this for initialization
void Start ()
{

}

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

if (Input.GetMouseButtonDown(0))

{

counter = counter + 1;

}

if (counter==15)

{
var position = new Vector3(332,258,0);
var objectPos = Camera.main.ScreenToWorldPoint(position);
Instantiate(azul, objectPos, Quaternion.identity);
counter = counter + 1;
}
}
}

hi,

just having a quick look, im not well up on this really, just throwing my 2p worth in :slight_smile:

so when you run the scene, you can still see it in the editor window? just not the game view?

is this a 2D scene? just wondering as ScreenToWorldPoint Z parameter is 0 (should work in orthographic mode) as this will be the position of the camera, and quite possibly the object is outside the cameras frustrum if in a perspective view.

try changing the Z value to the ‘camera.nearClipPlane’ or whatever Z depth from the camera you need.

see how that goes :slight_smile: