How do I fire rays from the camera in a 8x8 grid to cover the field of view?
I have an idea to make a portal occlusion system to make impossible geometry.
When a ray hits a portal, the sector is visible.
How do I fire rays from the camera in a 8x8 grid to cover the field of view?
I have an idea to make a portal occlusion system to make impossible geometry.
When a ray hits a portal, the sector is visible.
I’m using an 8x8 grid for my game as well!
Heres the code to select a tile:
private void UpdateSelection()
{
if (!Camera.main) return;
RaycastHit hit;
float rayCastDistance = 25.0f;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, rayCastDistance))
{
selectionX = (int)hit.point.x;
selectionY = (int)hit.point.z;
}
else
{
selectionX = -1;
selectionY = -1;
}
}
Mines using Cards on each tile so I send SelectionX and SelectionY into an 8x8 array containing their position shown here:
public void selectCardOnBoard(int x, int y)
{
if (cardPositions[x, y] == null)
{
//Debug.Log("Didn't work G");
}
if (selectedCard == null /*|| !selectedCard.moving || !selectedCard.attacking*/)
{
selectedCard = cardPositions[x, y];
Debug.Log(cardPositions[x, y]);
}
}
Hope this helps!