EECS 494 Metroid Tutorials

Configuring Tiles

As mentioned in the last section, our tiles only look nice, but they aren’t setup to function correctly.

In this section, we’ll show you how to make new Tile prefabs and update your prefabs to have new properties.

Running the “02-ModifyTilePrefabs” Script

The second script that we’ll be using is 02-ModifyTilePrefabs. As the name suggests, this script’s function is to update all of the tiles in our scene. Specifically, it can change the prefab of the tiles in the scene.

Open the window just as you did with the other Editor Script.

ModifyTilePrefabs

This script takes just a single parameter, TilePrefabMap, which you should supply with the included TilePrefabMap.txt under the Resources/Metroid folder.

This text file contains a map from the Sprite Sheet to what the prefab should be. You should open up the file to understand this relationship a bit more.

TilePrefabMap

Hit the Check Updates button. The window will tell you what’s happening:

PostCheck

The window is telling us it’s going to make a new prefab, Tile_WALL, and update ~5,000 of the tiles to use this.

In fact you can click on the scene to see which tiles are getting updated. As most tiles are walls, this is almost all of the tiles but you should notice a few exceptions with things like lava.

Updating a Tile Prefab

Now we have two separate Tile Prefabs: Tile_NONE which correctly has no properties, and Tile_WALL which is supposed to be solid, but also has no properties.

To add collission, we will be giving the Tile_WALL prefab a box collider. In the inspector for the prefab, click Add Component and add the Box Collider. Thankfully this collider is already the right size and position, so we don’t need to change anything else.

Tile_WALL

Conclusion

And that’s it! We just had to make a change to the one prefab, and all of the instances in the scene updated. This is the workflow you should use for configuring all of your tiles.

FunBall2

When you’ve committed and you’re ready to go, head over to 05-Player Setup.