• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Irin · Jul 23, 2016 at 07:50 AM · c#collisiondecal

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Irin · Jul 27, 2016 at 05:45 AM 0
Share

Here is a screenshot: alt text

"You'll need to offset the bullet holes" How do i do this?

2016-07-27-00-44-59-unity-personal-64bit-studio1un.png (225.9 kB)
avatar image Arshia001 Irin · Jul 27, 2016 at 06:46 AM 0
Share

You can do it like this:

 GameObject bulletHole = (GameObject)Instantiate (BulletHole, hit.point + hit.normal * 0.01f, transform.rotation);
avatar image Irin Arshia001 · Aug 02, 2016 at 05:36 AM 0
Share

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?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

199 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Attaching objects on collision 1 Answer

Collision on specific Frames 1 Answer

OnCollisionEnter for translating gameObjects? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges