- Home /
c# bullet holes appearing on collider
Hello! :) I am making a FPS and have a sphere collider on some prefabs placed on the floor. When i shoot my gun at the collider, my bullet hole appears on the collider instead of going through it. The colliders are set to 'Is Trigger' and are used so that i can pick up the weapon when i am inside the (sphere) collider.
Any help appreciated :) Here is some code responsible fore the bullet holes:
if (Physics.Raycast(shootPoint.position, shootDirection, out hit, range))
{
GameObject hitParticleEffect = Instantiate(hitParticles, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
//hitParticleEffect.transform.SetParent(hit.transform);
GameObject bulletHole = Instantiate(bulletImpact, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal));
bulletHole.transform.SetParent(hit.transform);
Nothing we can really do without the code you are using to spawn those holes
Are you sure the bullets have a rigidbody? or else the sphere.
Do you mean that you're using Raycasts for instant-trajectory bullets, then?
Answer by Casiell · Sep 23, 2018 at 09:01 PM
Looking at your code it looks like your raycast hits the sphere. Physics.Raycast has an optional parameter to use a LayerMask to only hit colliders that are on specified layers. You could create a layer for your sphere and just deselect it from mask
Your answer
![](https://koobas.hobune.stream/wayback/20220612174853im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
HOw to make a custom mesh collider 1 Answer
How can I disable this collider, when two are present on the gameobject 1 Answer
Multiple Cars not working 1 Answer
Zombie Damage Parts Problem 0 Answers
Distribute terrain in zones 3 Answers