making a vector from the raycast information

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

Try this:

function Update ()
{
     var hit : RaycastHit;
     if (Physics.Raycast (transform.position, fwd, hit, 30))
     {
          vec = hit.point;
          vec += hit.normal.normalized * 5.0;
     }
}

that works perfect, thanks alot

just following this thread and curious if this line has a typo:
vec += hit.normal.normalized * 5.0;

…was that supposed to be a + sign there instead of *?

Nope. It’s supposed to be be a *. Does the * not work for you?

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.