Как я сейчас размещаю префаб
Код: Выделить всё
if (delta.y != 0)
{
int xDir = Mathf.Clamp(delta.x, -1, 1);
int zDir = Mathf.Clamp(delta.z, -1, 1);
Vector3Int verticalOffset = new Vector3Int(0, delta.y, 0);
Vector3Int horizontalOffset = new Vector3Int(xDir, 0, zDir);
// Mark the grid as containing stairs
grid[prev + horizontalOffset] = CellType.Stairs;
grid[prev + horizontalOffset * 2] = CellType.Stairs;
grid[prev + verticalOffset + horizontalOffset] = CellType.Stairs;
grid[prev + verticalOffset + horizontalOffset * 2] = CellType.Stairs;
// Place the green cubes for stairs (this places them in the grid)
PlaceStairs(prev + horizontalOffset);
PlaceStairs(prev + horizontalOffset * 2);
PlaceStairs(prev + verticalOffset + horizontalOffset);
PlaceStairs(prev + verticalOffset + horizontalOffset * 2);
// Calculate the position of the stairs prefab
Vector3 stairPosition = new Vector3(prev.x + horizontalOffset.x, prev.y, prev.z + horizontalOffset.z);
stairPosition += new Vector3(0.5f, 0.5f, 0.5f);
Instantiate(stairPrefab, stairPosition, Quaternion.identity);
}
Как узнать направление движения лестницы и как разместить ее внутри зеленые кубики. Любая помощь будет принята с благодарностью
Подробнее здесь: https://stackoverflow.com/questions/793 ... b-in-unity
Мобильная версия