Hello, I am trying to write something to approximate a bullet shooting through a surface. I have a shoot ray giving me a shootHit.point, and I want to use that as my origin for the penetrationRay, but there are some instances where the object has 2 colliders within close proximity.
Originally I have:
penetrationRay.origin=shootHit.point-shootHit.normal;
But want to find a way to move the origin about a foot down in depth. I suppose this might have an issue when shooting from extreme angles, but I’ll give that some thought later, just wanted to know if its possible, and syntax of starting a ray at a point, about a foot negative from the normal of the surface.
Thanks!
shootHit.normal is already a normalized vector, so it’s length is 1… whether thats a “foot” in your game is dependant on your scale. Generally 1 unity unit of length = 1 meter, 1 unit measure of mass = 1kg etc. but if you’ve scaled everything so 1 unity length = 1 “foot” then it’s already 1 “foot”…
Thanks, I see that now, part of the problem was stemming from Debug.DrawRay not being in the update function, so not able to get a good look at it working.
Yeah you’ll want to multiply the “shootHit.normal” by whatever you deem the length of “1 foot” is in your game. By default a unity unit is implied to represent 1 cubic meter as is the default in many 3D programs, but you can use any scale you want as long as all your objects are the correct size to represent that scale.