I know Im doing something really boneheaded here but I can not seem to steer my raycasts towards colliders I know are there. There is a cube that represents the player’s tile, the for loop checks to see if there are already tiles in all 4 directions. When it recognizes there are not, it spawns an object indicating they are able to explore that tile. This code is not recognizing when tiles are already in place.
EDIT: I have cleaned up the code severely. I am still not doing something correctly. It is detecting correctly on the forward and the left raycasts, but is not detecting the collider on the back raycast, and the right raycast is detecting something that isn’t there.
function exploreLand()
{
currentGui=3;
MyCamera.transform.Translate(0,90,0);
MyCamera.transform.Rotate(Vector3.right*90);
//start checking adjacent tiles to player's land to see if they are explorable
var count = landtiles.Count;
for (var i = 0; i+1 <= count; i++){
var x : Transform;
x = landtiles*;*
-
var pos : Vector3 = x.transform.position; * -
if (x.GetComponent(tilescript).owner == 1){* -
if (!(Physics.Raycast(pos,x.transform.TransformDirection (Vector3.forward),10))){* -
Instantiate (tiletoexplore, pos + Vector3(10,0,0), Quaternion.identity);* -
}* -
else {Debug.Log("Collision detected1");}* -
if (!(Physics.Raycast(pos,x.transform.TransformDirection (Vector3.left),10))){* -
Instantiate (tiletoexplore, pos + Vector3(0,0,10), Quaternion.identity);* -
}* -
else {Debug.Log("Collision detected2");}* -
if (!(Physics.Raycast(pos,x.transform.TransformDirection (Vector3.back),10))){* -
Instantiate (tiletoexplore, pos + Vector3(-10,0,0), Quaternion.identity); * -
}* -
else {Debug.Log("Collision detected3");}* -
if (!(Physics.Raycast(pos,x.transform.TransformDirection (Vector3.right),10))){* -
Instantiate (tiletoexplore, pos + Vector3(0,0,-10), Quaternion.identity); * -
}* -
else {Debug.Log("Collision detected4");} * -
}* - }*