public void FindTarget(MotionType fallBack = MotionType.move) { RaycastHit hit; Vector3 castPos = TerrainGen.GetAsGridPosition(this.transform.position); castPos.y += 1; if (Physics.Raycast(castPos, Vector3.down, out hit, 3, buildingMask)) { if (!hit.collider.transform.parent.name.Contains("Copse")) { BuildingBase hitTarget; hitTarget = hit.collider.transform.GetComponentInParent <BuildingBase>(); if (hitTarget != null) { motionType = MotionType.attack; attackTarget = hitTarget; } } else { motionType = fallBack; } } else { motionType = fallBack; } }
void PlaceHexHook(Vector3 position) { Vector3 newPos; newPos = position; newPos.y += 0.001f; hexHook.transform.position = TerrainGen.GetAsGridPosition(newPos); }