- Home /
GameObject invisible at certain camera angles
both in the tab game that in the scene some meshes disappear when the camera is in certain angles and at a certain distance (unintended effect). these objects have a script attached that changes the material from a diffuse to a transparent (but only at the pressure of a button, and also to the neighboring mesh, which instead do not present the same problem).
but the problem occurs after i have changed material for the first time, then I also attach that code:
function Start() {
if(gameObject.GetComponent(Renderer) != null){
baseMaterials = renderer.sharedMaterials;
invisibleMaterial = new Material[1];
invisibleMaterial[0] = Resources.Load("Materials/Invisible", typeof(Material)) as Material;
}
}
public function SetVisible(enable : boolean) {
if (toBeRendered && gameObject.GetComponent(Renderer) != null){
if(enable && ceilingActive){
gameObject.renderer.sharedMaterials = baseMaterials;
gameObject.layer = 0;
}else{
gameObject.renderer.sharedMaterials = invisibleMaterial;
gameObject.layer = 2;
}
}
for (var child : Transform in gameObject.transform) {
var c = child.gameObject.GetComponent(ConstructionPart);
if(c != null)
c.SetVisible(enable);
}
}
I tried to act on the settings of the cam(but the problem is the same with the camera of the scene). No script act during movement of camera (in pause the problem is still there). I think at something connected with the invisible Shader or alfa testing problem ...
Edit: more information:
the meshs desapper when the floor isn't visible by the camera.
when disappeared the mesh don't cast shadow.
if i move them with scene tools, no longer present the problem...
the mesh is a cube witout the floor face
still no answer, I will also appreciate some idea. changing materials array can generate some side effect?
I guess it's just a problem of the material, for now I solved disabling and enabling the renderer ins$$anonymous$$d of changing material with the invisible ... but this is not a good solution :(
Your answer
Follow this Question
Related Questions
How to make first person model invisible 1 Answer
Mesh junctions flickering? 0 Answers
how to turn of the mesh renderer when the player isn't looking 3 Answers
Mesh line renderer - line segments camera align 1 Answer
No renderer at top level 1 Answer