Using Unity to Create GBA games pt. 2


We are working on a bridge between Unity and Butano to facilitate our creation and editing of scenes, we will make the tool available for free when it is finished.

In our last post regarding using Unity to create scenes for butano, we were doing a lot of repetitive tasks, like exporting the tilemap as PNG and using Usenti to convert to an 8-bit BMP. This is no longer necessary, we have automated this process by creating a script that not only creates the image in the correct format, but also the respective JSON. We only need 2 reference points to tell us where the tilemap starts and ends, the reference of the tilemap itself and finally the size (in pixels) of each tile (in our case we are using 16).


The two reference points also allow us to directly convert from Unity coordinates to GBA coordinates, with simple code:

    public Vector2Int UnityToGBAPosition(Vector2 pos)
    {
        float posx = (map.size.x*cellSize * (pos.x - leftDownCorner.position.x))/
                     (rightUpCorner.position.x - leftDownCorner.position.x) -
                     (map.size.x*cellSize/2);
        float posy = -((map.size.y*cellSize * (pos.y - leftDownCorner.position.y))/
                      (rightUpCorner.position.y - leftDownCorner.position.y) -
                      (map.size.y*cellSize/2));
        
        return new Vector2Int((int) posx, (int) posy);
    }

We've also created a standard camera that has exactly the same view as a camera on the GBA using butane, allowing us to see exactly how the game will look on the Gameboy Advance screen.



Get Green Memories

Leave a comment

Log in with itch.io to leave a comment.