Can someone help me understand scriptable tiles? I’ve watched some videos, and I’ve read the documentation, but for some reason I just don’t get what they are or how they are used?
They are used to add or extend tiles beyond what is offered within TileBase. The 2d extras package is very good for examples.
Some examples of custom tiles: RandomTile, RuleTile, AnimatedTile. Generally these specialized tiles have behavior that dictates rules around tile selection and placement.
You should keep in mind that you can’t access tiles as individual objects as they are rendered at once, this is what makes them performant. If you need tiles to have behavior at runtime, you need to use a hybrid approach. You can spawn a gameobject that is associated to the tile.
If the tile needs to move (e.g. actor, character), you are best using a gameobject that isn’t tied to any tile. The aforementioned gameobject is effectively tied to the “soft” instance of the tile. If the tile is reset on runtime, the gameobject goes with it.
These 2 scenarios are likely more complex that what you are seeking. I would suggest installing 2d extras (it can be installed as a package in 2019.2 and 2019.3). This package alone make cover your needs.
So what I’m looking for is a solution to a problem I’m running into with making a ledge hang mechanic. I want corner tiles to be able to be grabbed. I could of course go through and do all of these individually so they are separate from the composite collider that makes up the rest of the tiles, but this is much more time consuming than if I can find a way to let Unity know to programmatically do this when I place a corner tile. I’m fairly new to using tiles and 2d in general so forgive me if this doesn’t make much sense or is completely impossible. lol.
@eforbes
Nothing is impossible :).
If I had to solve the same problem, i’d opt to use a tile without a predefined collider. I would instead instantiate a prefab in the same position as the tile with a collider that is intended to handle standard collisions and another collider that handles grappling.
Consider the mockup and assume a platform:
The TileMap Composite collider can be used as is, just a standard tile collider. The collection of left and right cliff and grapple colliders would need to “live” on a prefab associated with the left or right tile. The grapple colliders would allow you to “detect” when you need to grapple vs perform standard collision.
You can see my post here to determine how to add define a prefab tile.
Admittedly, you may not want to go through the trouble of doing this as grappling isn’t a simple problem to solve.
Hope this helps a bit. Best of luck