Notifications
Example of Map Destruction at Runtime
Showcase
427
0
The idea was to create a way for the player to have a terrain that they can modify at run time.
If you want to have a look at the code behind this destruction, it's available here: https://gist.github.com/Westerveld/c0cf2fc3fe005e9f387e6769ad2a95a9
The idea is to do the following:
  • Get the direction we are facing
  • Raycast in that direction
  • Check if the raycast is colliding with an object that has a tilemap
  • If it does, we remove the tile at the location where the collision happened. We make sure to floor the float as the tile anchor points are at the bottom left. i.e. if we raycast to the position (0.9,1.5), we want to destroy the tile at (0,1)

Unity Evangelists
5
Contributors
Ethan Bruins
Programmer - Student
Comments