Skip to main content

Use Case 2 TileMaps and Triggers

Use Case 2

Problem Statement

We have a player, and we want it to not pass through the outer tiles of the tilemap. We will use the solid property on the tiles to add a collider. Also, we want the player to step on a trigger to show a prize.

Demonstrates:

  • Tilemap colliders
  • Triggers
  • Collectibles
  • Spawning

Using the demo:

  • WASD to move the orange player
  • The gray tiles are solid
  • The black circle is a button to press
  • Pressing the button drops a coin to pick up
  • Rinse and repeat

Takeaways from this use case

Tilemaps can set the solid property on tile for any of the tiles

You can build whatever wall layout and each tile will have a collider on it.

Triggers can be used instead of Actors

Triggers are a special type of entity that can be less expensive than using an actor for just triggering a collision event.