Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
themars2011

Queries hit backfaces not working

Question

Hey guys,

 

I am currently working on bullet penetration for my kit and I came across a physics issue. 

Queries hit backfaces is set to true, but my Raycasts are not hitting backfaces at all. I tried box colliders and mesh colliders (convex and not) and none were working.

Here you can see it:

78426e2f44a6bc37aeb6559bee443653.gif

 

Any clues to what might be going on?

 

I am using a while loop for raycasts that continues if the object was penetrated and as you can see it's pretty much working but it just does not hit the backside of the cube.

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Have you checked by pausing it and seeing where the decals are positioned in the editor. There could be decals on the backfaces, but they are rotated to face the player's shooting position so you cannot see them.

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

 

Yes, there is only one decal and particle on each cube. I was thinking the same, maybe it was applied inwards, but that is not the case.

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

They aren't triggers, normal Box/Mesh colliders with isTrigger set to false

Share this post


Link to post
Share on other sites
  • 0

If you aren't using Unity 5.6 or later it could be this bug:
Please login or register to see this link.

 

You could try debugging the hit points of each ray to see if the backfaces are included. This will tell you if its a bug with Unity or your code.

 

You could try creating a duplicate of each cube and reversing the normals. See what happens.

 

Could be culling related (back face culling), but I have no idea if culling effects the physics engine or not, maybe it only effects rendering.

 

One obvious solution is to execute all your raycasts twice. Once in each direction, but doubling the raycast count is not ideal.

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

Yeah I just saw the documentation. Didn't even know there was a feature like this :P 

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

I actually tried that first because it seemed like the easier way (was already set up that way) but the result is the exact same unfortunately.

Share this post


Link to post
Share on other sites
  • 0

I'm sorry to necrobump this, but I'm wondering if you ever found a solution?

 

I am having the same problem, though I'm using RaycastAll. It seems like when I enable backface hits, I do get two hits for each object- but instead of one hit on the front face and one on the back (like I'd expect) I get two hits of the same face, same point and same normal.

 

Is this possibly a Unity bug?

 

It doesn't seem like an unusual use-case to want to shoot through something....

 

EDIT: Nevermind, extra-sorry for the necro. Seems like setting this flag via code doesn't work, when I set it in the editor instead it seems fine.

Edited by NathanWolf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×