How to change tiles at runtime in Unity (Burn your tilemap!)

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ค. 2020
  • In this video I show you how to set your tilemap on fire, including how to change tiles via script.
    Get the full project here (free) : github.com/ShackMan2000/Tutor...
    The part where the tiles are changed:
    • How to change tiles at...
    Get the fire prefab:
    gofile.io/d/EDqHKj
    How to make the fire animation:
    • How to create cartoon ...
    How to store data in tiles with Scriptable Objects:
    • How to store data in t...
    Check out my newest game Idle Potato Power. It's a fun and relaxing game about exploring Potato Power in all it's multidimensional weirdness.
    play.google.com/store/apps/de...
    github.com/ShackMan2000
    Discord: / discord

ความคิดเห็น • 32

  • @_Orothin
    @_Orothin 3 ปีที่แล้ว +5

    Awesome video! Looking forward to the automatic object pool video you mentioned you're planning in the future.

  • @rahulnaik2757
    @rahulnaik2757 ปีที่แล้ว +2

    Awesome tutorial...looking forard to more advanced unity tutorials from you

  • @benbarney9524
    @benbarney9524 3 ปีที่แล้ว +6

    This was exactly what I needed, Thanks!

  • @crimson_roselia669
    @crimson_roselia669 ปีที่แล้ว +1

    Good tutorial! Helps me solve some problem with unity tilemap. :)

  • @tammy87774
    @tammy87774 3 ปีที่แล้ว

    Thank you for this video. Really helped me

  • @VoixDeLaNation
    @VoixDeLaNation ปีที่แล้ว +1

    Amazing video I'm improving my Tilemap understanding a lot ! What if I want to keep the tile and its properties (in the tile script) but I just want to have different animations that I could spawn randomly or change through script ? Do i need another Animated Tile/Rule Tile in my scripted Tile to do it or is there another way ?

  • @aayushtiwari1420
    @aayushtiwari1420 ปีที่แล้ว

    Helped alot 😊

  • @deaddoctor
    @deaddoctor 3 ปีที่แล้ว +5

    When I do SetTile(pos, tile) it only changes in the scene view but not in game, ClearAllTiles() works though.
    EDIT: I fixed it by setting the z value of pos to 0 (pos.z = 0)

    • @bruninhohenrri
      @bruninhohenrri 2 ปีที่แล้ว

      Thank God, you saved my life here.

  • @firewalkswithme
    @firewalkswithme 2 ปีที่แล้ว

    OMG GOOD JOB thank you

  • @Jamifa007
    @Jamifa007 2 ปีที่แล้ว

    So, in the last video, you changed the grid's cell size from its default value of 1 to fit the sprites. I'm guessing that doesn't change how the Vector3Int works to find a specific tile, then?

    • @ShackMan
      @ShackMan  2 ปีที่แล้ว +1

      Yes, it shouldn't matter. It's basically just a database that keeps track of which cell is next to each other, 000 is next to 100 etc. , no matter how big they are in the world.

  • @jadimatic1096
    @jadimatic1096 3 ปีที่แล้ว +2

    I'm trying to make cellular automata in unity's tilemap and I was thinking of reworking the fire from this into a tile updater, however I feel like there is probably a better way to get every tile position and update them, if so, could you perhaps make a video on that?

    • @ShackMan
      @ShackMan  3 ปีที่แล้ว +1

      I think I would first loop through them and add every tile to a list. Use Tilemap.origin to get the lower left corner and Tilemap.origin + Tilemap.size for the top right corner. Then when you want to update the tiles, you can just use a foreach loop on the list where every tile is. Depending on the size of the tilemap, this might be quite performance heavy. Greetings

  • @anthemsofnations
    @anthemsofnations 3 ปีที่แล้ว

    Hello! I've done everything except for using the same fire prefab that you used and nothing is really working. I've been trying to solve this problem but I can't figure it out. I'm not even sure if the prefab is the problem.

    • @ShackMan
      @ShackMan  3 ปีที่แล้ว

      Sorry, late answer... You have to be more specific, is there an error message?

  • @boreal3255
    @boreal3255 2 ปีที่แล้ว +1

    Snippet for a tilemap editor: map.SetTile(grid.WorldToCell(cam.ScreenToWorldPoint(Input.mousePosition)), tile);

  • @annoyed2303
    @annoyed2303 3 ปีที่แล้ว +1

    Clicking the link for "the part where the tiles are changed" just sends me to 0:00?

  • @pavelholub6275
    @pavelholub6275 2 ปีที่แล้ว

    Content of this tutorial is Awsome. Story and complexity of series is great, but that names o variables in script are pain for newbies. Like Vector called mouseposition which you set as ...Input.mousePosition, same with data and others. To become Brackeys no.2 you need to be more newbie-friendly. But anyway this is 9 stars of 10, because unique content. Definetly like this channel.

    • @ShackMan
      @ShackMan  2 ปีที่แล้ว

      Thanks for the feedback! At the current rate my channel is growing I will be Brackeys no.2 around the year 2350....

  • @TheDonuts97
    @TheDonuts97 3 ปีที่แล้ว +1

    How do you get the current position of the tile you want to change?

    • @ShackMan
      @ShackMan  3 ปีที่แล้ว

      I'm not sure what you mean, the first tile clicked? Can you describe more or give me a timestamp or line of code you are referring to? Greetings

    • @TheDonuts97
      @TheDonuts97 3 ปีที่แล้ว

      @@ShackMan I don't have much of a full understanding of the tilemap system in Unity so apologies if I can't explain properly. All I'm trying to do in my game is replace a tile with another at runtime, similar to when you change the tile to an ash tile. To do that you need to know the position of the tile burning. In the code at 3:00 you define it, but I'm having trouble seeing where that position is actually connected to a tile in the editor.

    • @ShackMan
      @ShackMan  3 ปีที่แล้ว +1

      @@TheDonuts97 at 8:54 is where we check for a mouse click and convert that from screen position, where the mouse is, to a grid position. Let me know if that is still unclear, it helps me to know how well people understand my videos.

  • @HarryBGamer2570
    @HarryBGamer2570 2 ปีที่แล้ว +1

    how can i make it so it burns in a star shape?

    • @HarryBGamer2570
      @HarryBGamer2570 2 ปีที่แล้ว +1

      ok, i did it! I just made a check if the x and y values combined were larger than the current number of iterations in the TryToSpread method
      if (Mathf.Abs(x) + Mathf.Abs(y) > iteration) continue;

  • @hc5831
    @hc5831 3 ปีที่แล้ว

    Great video. Can you post this code on Github?

    • @ShackMan
      @ShackMan  3 ปีที่แล้ว +4

      Thanks, good idea! I've uploaded it and added a link in the description. I'll try to upload the code for all future tutorials. Cheers

    • @hc5831
      @hc5831 3 ปีที่แล้ว

      @@ShackMan Thanks. You are providing good intermediate tutorials. I appreciate it. :)

  • @academiadoscoins9034
    @academiadoscoins9034 11 หลายเดือนก่อน

    My unity editor crashed!
    Every time I run your script the editor crashes and I have to force it to restart.
    There is a bug in your code

  • @BSCRIBE-oe6kx
    @BSCRIBE-oe6kx 2 หลายเดือนก่อน

    BSCRIBE!

  • @BSCRIBE-oe6kx
    @BSCRIBE-oe6kx 2 หลายเดือนก่อน

    BSCRIBE!