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!