Instantiated objects are dark in color

This is my project : http://unity.azmangames.com/hataBuild.html

Problem is when I instantiate an object from the raycast, clone object is very dark in color. Maybe this is a very basic thing but I couldn’t figure out why. I checked materials, I checked shaders, I even put lights on new object but nothing helped. Here is my instantiate code :

Many thanks in advance.

(in FixedUpdate)

 Ray ray2 = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit2;
        
        if (Input.GetMouseButtonDown(0))
        {
            if (Physics.Raycast(ray2, out hit2))
            {
                if (hit2.transform.tag == "resim")
                {

                    klonRes = new GameObject();
                    klonRes.name = "klonRes";

                    klonResim = Instantiate(hit2.transform.gameObject, hit2.transform.position, new Quaternion(0, -180, 0, 0)) as GameObject;
                    klonResim.transform.localScale = new Vector3(klonResim.transform.localScale.x + 10, klonResim.transform.localScale.y + 10);
                


                    klonResim.transform.parent = klonRes.transform;
                    resimTakipEdiyor = true;

                }

               
            }



        }

        if (resimTakipEdiyor) //resim ekleme
        {
           
            Vector3 point = ray2.origin + (ray2.direction * 85);
            klonResim.transform.position = point;

        }
        if (secilenTakipEdiyor) //resim taşıma
        {
            Vector3 point = ray2.origin;
            secilenResim.transform.parent.position = point;


        }

        if (Input.GetMouseButtonUp(0))
        {

            resimTakipEdiyor = false;
            secilenTakipEdiyor = false;
          
     

        }

did you check materials and shaders of the object after they instantiated? I am assuming your gameObject is not giving this effect when you simply drag it into the scene in editor mode.

Is your gameObject a prefab so that it can carry over all the materials when you make clones in your script?

  1. Check the normals on your model to make sure they are correct
  2. Make sure your instantiated GameObject is on a render layer that is affected by your lights.

I checked the clone objects materials and it’s identical to the origin object. I even change the color of original object and the clone’s color is changing too.

I’m using the Unity Cube so normals must be okay. I’ll check the light layer.

Many thanks for your replies.

I am not sure about this line:

klonResim.transform.localScale = new Vector3(klonResim.transform.localScale.x + 10, klonResim.transform.localScale.y + 10);

You left Z as zero, I think the shader may have a problem when the modell is basically scaled to be flat.

1 Like

You sir, rock! :slight_smile: That solved the problem, many many thanks.