Raycast help.....

Hi,

I was wondering how or if you can cast a diagonal ray in unity. see in my game one of the players weapons is a shotgun and i wanted to cast 3 rays from the player eg. one going straight forward and one on either side going around 45 degrees. is this possible ? how would i do it ? could i cast a ray from point A to point B with both Point A and B having a (x,y,z) location? code would be great thanks :)

Read up on the documentation on raycasting..

i was wondering why this code doesn't work ? i want to just cast a ray and what ever it hits returns a print statement is my Debug.Draw ray correct ?

var xDirection = 15;

var yDirection = 0; var zDirection = 45; var length = 0.1; var hit : RaycastHit;

function Update () { var diagonal = transform.TransformDirection (Vector3(xDirection,yDirection,zDirection)); Debug.DrawRay(transform.position, diagonal * length,Color.green);

if (Physics.Raycast (transform.position, diagonal,hit,length)) {
    print ("There is something in front of the object!");
}

}

help please

thanks