# how to offset a rays starting point

So the problem i am working with here is about rays piercing objects. Basically, a ray is created, it hits a piece of armor, and then some math happens, if it is able to pierce the armor, then I need it to create a ray just past it, moving in the same direction. Ive already figured out the math for if it can pierce the armor, I think i can figure out the direction part, i just need to know how to offset the position. I dont think i can just add an x or y constant variable for this reason: The green is the initial shot, and the blue is the second ray that needs to be created. If its hitting like this, its pretty easy, you would just offset the starting position of the ray by a little bit on the x axis. But it might not always hit like that. What if it hits like one of these: I accidentally inverted the colors of the rays but my point still stands.

I cant just add an x value to the starting point of both of those secondary rays. For one, it would work alright, but the other, that would put it back outside of the armor and just hit it twice. And this project is in 3d, so there's a z coordinate to deal with as well. What i would need to do is add a value to the origin of the secondary ray that is a few units forward of the first ray's eventual impact point. And that is what I can't figure out how to do.

• Yes, you take 2 edges of your face and take the cross product to get the normal vector. For a triangle made of vertices A B C this would look like to_unit_vector(cross(A-B, C-B)) Jul 8 at 16:35
• well, thats not what i did. i just used this line of code: if(Physics.Raycast(projectileHitPoint + (new Vector3(hitInfo.normal.x, hitInfo.normal.y, hitInfo.normal.z)*0.001f), projectileSpawnPoint.forward, out secondaryProjectile, 100f)) ProjectileHitPoint is just where the last ray hit. This way works just fine to me Jul 8 at 16:53