Can't get my raycast to work, Debug.DrawRay also isn't working.

Hey guys, there is probably a really simple answer to this but I can’t get this raycast to work.

Here is the code :

#pragma strict

static var BlockSpawn_1Dist : int;
static var BlockSpawn_2Dist : int;
static var BlockSpawn_3Dist : int;
static var BlockSpawn_4Dist : int;
static var BlockSpawn_5Dist : int;
static var BlockSpawn_6Dist : int;
static var BlockSpawn_7Dist : int;
static var BlockSpawn_8Dist : int;
static var BlockSpawn_9Dist : int;
static var BlockSpawn_10Dist : int;

var rayDirection : transform.forward;
var rayDistance : float = 100f;

var hit : RaycastHit;

function update () {

    if (Physics.Raycast(transform.position, rayDirection, hit, rayDistance)) {
        BlockSpawn_1Dist = hit.distance;
    }
    Debug.Log("First spawn measured");
    Debug.Log(hit.distance);
    Debug.DrawRay(transform.position, rayDirection * 20, Color.green);
    }

If someone could help me fix this it would be great. Has had me stuck for a while now. Thanks!

So this is an example from the API that is a bit lacking. It shows you everything you need to have a line drawn but neglect to mention that it defaults the duration to 0 secs:

public static function DrawLine(start: Vector3, end: Vector3, color: Color = Color.white, duration: float = 0.0f, depthTest: bool = true): void;

So make it look like this:
Debug.DrawRay(transform.position, rayDirection * 20, Color.green, *20);

this will make your line visible for 20 seconds

Hope this helps!

@Redwolve
Okay, I will give this a try. Thanks for your help and the quick response, I really appreciate it!