Ejemplo n.º 1
0
    void RaycastTilePosition(ref Vector3Int worldPos, ref Vector2Int tilePos)
    {
        if (mapRoot == null)
        {
            return;
        }
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        // get the collision point of the ray with the z = 0 plane
        Vector3 worldPoint = ray.GetPoint(-ray.origin.z / ray.direction.z);

        worldPos = grid.WorldToCell(worldPoint);
        tilePos  = PositionMath.GridPositionToTilePosition(worldPos);
    }