private void RayCastObjects() { RaycastHit tableRay; Debug.DrawRay(transform.position, transform.forward, Color.red); if (Physics.Raycast(transform.position, transform.forward, out tableRay, tableRayDistance)) { TableBehaviour table = tableRay.collider.GetComponent <TableBehaviour>() != null?tableRay.collider.GetComponent <TableBehaviour>() : null; if (table == null) { tableManager.ClearActiveTable(); return; } tableManager.SetActiveTable(table); } else { tableManager.ClearActiveTable(); } }