I want to do 4 raycasts diagonally, one between forward and left, left and backward, etc… I have this code right now:
var adjustedPoint : Vector3 = Vector3(hit.point.x, hit.point.y + .5, hit.point.z);
//If building placement location is inside of (or on top of) another obstacle, don't place it
if (Physics.Raycast (ray, hit, 100, (1 << 10))) {
obstacleInWay = true;
Debug.Log("Obstacle in path, building cannot be placed");
}
//If other buildings are located nearby, don't place the building
//parameters for spherecast are: (origin, radius, direction, hitinfo, distance, layerMask)
//check against positive x
if (Physics.SphereCast (adjustedPoint, .2, Vector3(1,0,0), hit, 3, (1 << 10))) {
obstacleInWay = true;
Debug.Log("Obstacle in path, building cannot be placed");
}
//check against negative x
if (Physics.SphereCast (adjustedPoint, .2, Vector3(-1,0,0), hit, 3, (1 << 10))) {
obstacleInWay = true;
Debug.Log("Obstacle in path, building cannot be placed");
}
//check against positive z
if (Physics.SphereCast (adjustedPoint, .2, Vector3(0,0,1), hit, 3, (1 << 10))) {
obstacleInWay = true;
Debug.Log("Obstacle in path, building cannot be placed");
}
//check against negative z
if (Physics.SphereCast (adjustedPoint, .2, Vector3(0,0,-1), hit, 3, (1 << 10))) {
obstacleInWay = true;
Debug.Log("Obstacle in path, building cannot be placed");
}
How can I get a diagonal vector between say “Vector3(1,0,0)” and “Vector3(0,0,1)”, the positive x and z direction vectors.
Thanks for any help or ideas.