I have been trying to get my helicopter’s raycast line to collide with the terrain so that when the line collides with the terrain, something happens. For now I just put print for testing/debugging purposes.
I do not have a lot of experience with this Ray-casting business. What am I doing wrong?
Here is my code:
#pragma strict
public var Player : GameObject;
public var Follow : GameObject;
public var terrain : Terrain;
function Update () {
var hit : RaycastHit;
Debug.DrawRay(transform.position, transform.up * 3, Color.red);
if(Physics.Raycast(transform.position, transform.up, hit, 3)) {
if(hit.collider.gameObject == terrain){
print("You hit the Terrain.");
}
}
}