arrow-left

All pages
gitbookPowered by GitBook
1 of 2

Loading...

Loading...

Adjacency Connections

The design of the system can be found in the the link below.

Adjacency connections refers to when a tilemap object is connectable to its neighbors, walls being the typical example of this.

hashtag
Adjacency Connectors

In order to make walls and tables connect to each other, you need to make use of a adjacency connector. This keeps track of which neighbours it is connected to and will replace and rotate meshes accordingly.

hashtag
The different adjacency connectors

There are different types of adjacencies supported right now.

  1. Simple - Used for simple connections without a lot of use cases. Covers the basic shapes such as I, U, O, T and X.

  2. Advanced - Expansion of the Simple type with a lot more edge cases covered.

  3. Offset - Used for meshes which are not placed in the middle (thus offset). Used by pipes for example.

hashtag
Implementing an adjacency connector

The first thing you need is to implement the IAdjacencyConnector interface.

If your tile object connects only with things from the same layer, adjacent to it, you might want to look at the AbstractHorizontalConnector class and inherit from it.

It will only ask you to implement the IsConnected() method, as it varies a lot from one connector to another. Door, simple, advanced, offset, pipe all inherits from it. Chances your connector could too.

If the connections are weirder, such as disposal pipes able to connect to disposal furniture, a different object on a different layer, with a different connector, and with special behavior when it connects, then directly implement the IAdjacencyConnector interface.

hashtag
Make a tile object connectable

Add the right adjacency connector script to your prefab's root game object. You can recognise a Connector script because it implements the IAdjacencyConnector interface. To know which specific script to use, check the connectables design pages.

Connectable scripts usually ask you to add specific mesh for specific configurations. You need to fill them all up for the connector to work properly.

Check the Connectables design page for more informations about your specific connector and how the meshes should look.

Also know that the connectables scripts assume the mesh you link are rotated in a specific fashion, otherwise they may appear incorrectly in game. If you have this issue of meshes badly rotated, try to rotate the models you use, out of the game.

Disposal Furniture - checks if connected from above to a disposal pipe. Very specific one.

  • Disposal Pipe - Used for disposal pipes only.

  • Door - Specific to doors, because of the specific way it connects to other doors and to walls.

  • Pipe - For pipes with an offset (not centered on the tile)

  • A wall adjacency connector

    Adding new items & objects

    hashtag
    Creating ScriptableObjects

    To add a new item or object to the tilemap system, a new scriptableobject needs to be created.

    Right click in the Unity Editor to create a new object

    hashtag
    Location

    Make sure to save the item/tile ScriptableObjects under the corresponding "Content/Data/TileMap/Resources/" folder

    hashtag
    Details

    The following information can be filled in for a TileObjectSo:

    hashtag
    Tile objects

    • Name String - describes the name of the object

    • Prefab - which prefab to spawn

    • Icon - Icon which is used by the creator and construction interface

    hashtag
    Items

    Items can be added in a similar way:

    circle-exclamation

    Make sure the Name String is unique. Not doing so will create issues during loading & saving.

    Layer - which layer the item should be put in
  • Generic Type - Generics types are used to categorize objects on the same layer. Used by the adjacency connector to connect walls for example

  • Specific Type - Specific types are used to specify the material that the object is made of. For example used by carpets to ensure that they don't connect to other floors

  • Width - width of the object. Used for multi-tile objects

  • Height - height of the object. Used for multi-tile objects

  • Details to fill in
    Items follow the same approach
    spacechevron-right