private void OnSelect() { // Get the selected tile from the selection indicator/mouse Vector2 pointerPosition = Pointer.current.position.ReadValue(); Ray ray = Camera.main.ScreenPointToRay(pointerPosition); if (!Screen.BattleMapGfx.GetComponent <Collider>() .Raycast(ray, out RaycastHit hitInfo, Mathf.Infinity)) { return; } Vector3 pointerCoordinates = Screen.BattleMapGfx.transform.InverseTransformPoint(hitInfo.point); int x = Mathf.FloorToInt(pointerCoordinates.x / Screen.BattleMapGfx.TileSize); int z = Mathf.FloorToInt(pointerCoordinates.z / Screen.BattleMapGfx.TileSize); Vec2 tileSelected = new Vec2(x, z); // Do some basic verification that the tile wont be rejected by the engine. No point in telling the // engine if it is just going to throw the action away. Actor actor = Screen.Game.CurrentActor; PathfindingGrid tiles = Screen.Game.BattleMap.Tiles; GridNode position = tiles[actor.Position]; IDictionary <GridNode, GridNode> moveableTiles = tiles.FloodFill <DijkstraFloodFill>(position, actor.Speed, actor.Motility); GridNode destination = tiles[tileSelected]; if (!moveableTiles.ContainsKey(destination)) { return; } // Send the StrideAction to the engine for processing Screen.Game.CurrentActor.SetActivity(new StrideAction(Screen.Game.CurrentActor, tileSelected)); Screen.TransitionState(new AnimatingState(Screen)); }