im raycasting at a wall, and i want to make a vector at the point the contact happened but a little bit off the wall
so i did this
function Update () {
var hit : RaycastHit;
if (Physics.Raycast (transform.position, fwd,hit,30)) {
vec= Vector3(hit.point.x+5,hit.point.y,hit.point.z);
}
and that works if im doing it on one side, but if i try to do it on the other side it goes 3 into the wall, instead of 3 in front of it
I get why this is happening but i don’t know how to fix it
That line actually does move the starting point 5 units along the surface normal.
hit.normal.normalized returns the normal vector with a length of 1, multiply that by five, add to hit.point vector.