- Home /
Bullet Decal not visible unless i clip through the object.
I have a wall that i am using to test bullet decals on. I placing them with a Raycast. Now the decals never show unless i literally move my character up close to the wall until my camera is viewing though the wall. is this a clipping issue?
//Fire Mechanisms.
if(Input.GetButtonUp("Fire1"))
{
hitray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f,0));
if (Physics.Raycast(hitray, out hit, 1000.0f))
{
point = hit.point;
Spawn.transform.LookAt(point);
print(hit.collider.name);
if (hit.collider.transform.CompareTag ("Wall"))//place decals when it hits the tag wall
{
GameObject bulletHole = (GameObject)Instantiate (BulletHole, hit.point, transform.rotation);
bulletHole.transform.parent = hit.collider.transform;
}
Health enemyHealth = hit.transform.GetComponent<Health>();
if(enemyHealth != null)
{
enemyHealth.Damage(damage);
}
Debug.Log (hit.transform.name); // logs it into the console
}
Id attach an image but i dont meet the requirements of the 524Kb even though the image is 517Kb
Answer by Arshia001 · Jul 23, 2016 at 08:53 AM
From your code, it looks like you're spawning the decal at the exact point of collision. This will cause depth-fighting issues. You'll need to offset the bullet holes or use a shader with no depth checking. Another thing that comes to mind is that maybe the orientation of the decal is wrong, so you're viewing the backface and the frontface is only visible when you move the camera to the other side and into the wall? Without a screenshot it's really hard to tell.
Here is a screenshot:
"You'll need to offset the bullet holes" How do i do this?
You can do it like this:
GameObject bulletHole = (GameObject)Instantiate (BulletHole, hit.point + hit.normal * 0.01f, transform.rotation);
So i did as you said, but im still having the same issue. $$anonymous$$aybe its the orientation of the decal, what should i look for to ensure that it is facing the right way?