playMaker

Author Topic: Tilemap Actions Package  (Read 4174 times)

Plancksize

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 75
Tilemap Actions Package
« on: April 23, 2021, 02:36:50 PM »
I've been playing around with a little project that involves Unity's Tilemap system and due to the lack of actions for that system I've created a few ones for the project. I tweaked them a bit to fit general use and packed them into the attached package.

It includes 33 tilemap actions:

Clear All Tiles
Create Tile from Sprite
Get Rule Tile*
Get Rule Tile Instantiated Object*
Get Tile
Get Tile Color
Get Tile Rotation
Get Tile Sprite
Get Used Tile Count
Has Tile
Set Random Tile
Set Rule Tile*
Set Tile
Set Tile Color
Set Tile Rotation
Swap Tiles
Tile Cell to Local
Tile Cell to World
Tile Compare
Tile Flood Fill
Tile Local to Cell
Tile World to Cell
Tile Move
Tile Refresh
Tile Refresh All
Get Tilemap
Get Tilemap Owner
Tilemap Compress Bounds
Tilemap Get Bounds
Tilemap Resize Bounds
Tilemap Get Color
Tilemap Set Color
Tilemap Get Content to Array

* Requires Unity's "2D Tilemap Extras" package, available through preview packages on the package manager.

- Updated: Fixed ErrorCheck condition
« Last Edit: May 02, 2021, 10:40:30 AM by Plancksize »

Lost Dragon

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Tilemap Actions Package
« Reply #1 on: May 02, 2021, 12:39:58 AM »
Hi.

In SetTileColor at this line:

Code: [Select]
if (tilemapObject.Value == null && tilemap.Value == null)
return "Either a Tilemap or a GameObject with a Tilemap is required.";

Should the && be ||

Thanks for the actions.  8)

Plancksize

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 75
Re: Tilemap Actions Package
« Reply #2 on: May 02, 2021, 06:16:33 AM »
Woops! good catch.  :-[
PS:
Upon looking at that error check part of the code, the && is correct.
It'll verify if both are null, and if both are null (meaning, no provided way to retrieve a tilemap component) it'll throw the error log.
« Last Edit: May 02, 2021, 10:36:36 AM by Plancksize »

sunzifu007

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Tilemap Actions Package
« Reply #3 on: October 27, 2021, 02:26:24 AM »
Thank you very much. That's exactly what I need.

Lost Dragon

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Tilemap Actions Package
« Reply #4 on: February 08, 2022, 02:30:24 AM »
It took me a while to figure out why I was getting weird results with these actions and then I realized you use Mathf.RoundToInt

For anyone who has characters on a map with an offset grid of .5 like I do then you want to change Mathf.RoundToInt in these actions to Mathf.FloorToInt



8bitbrainpower

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Tilemap Actions Package
« Reply #5 on: August 16, 2022, 11:12:52 AM »
Looks amazing. However upon importing, the console display errors and the actions does not appear in Playmaker action browser. Unity package "2D Tilemap Extras" was installed before trying to import the actions.
My Unity version is: 2021.3.7f1, and Playmaker version is: 1.9.4.f2

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Tilemap Actions Package
« Reply #6 on: August 17, 2022, 12:38:43 AM »
Hi.
There errors show that there  are duplicates of those files.

search your project for the .cs files (GetTile.cs / SetTile.cs)

8bitbrainpower

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Tilemap Actions Package
« Reply #7 on: August 17, 2022, 04:39:09 AM »
Hi.
There errors show that there  are duplicates of those files.

search your project for the .cs files (GetTile.cs / SetTile.cs)

Thank you very much! Indeed I had these other tilemap actions installed that were conflicting. Now all good ;)

PatternTree

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Tilemap Actions Package
« Reply #8 on: October 22, 2022, 11:28:22 AM »
All of these only seem to work for a rectangular tilemap whereas I'm using it for a hexagonal grid. For example, when I try to calculate the world to cell position, I only get results that line up on a rectangular grid.

Is there any chance of getting actions that help with a hex grid instead or at least some instructions on what needs to be changed in order for these actions to work on a hex grid?

Will definitely use these for rectangular grids, though! Thank you, they're amazing!

Plancksize

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 75
Re: Tilemap Actions Package
« Reply #9 on: March 07, 2023, 10:05:55 AM »
All of these only seem to work for a rectangular tilemap whereas I'm using it for a hexagonal grid. For example, when I try to calculate the world to cell position, I only get results that line up on a rectangular grid.
....

I'm very late for this, and sorry if I've been missing any request around here. Been a bit forgetful of the forum.

This is a weird issue since the action uses WorldToCell from Unity.Tilemaps (I didn't add any extra code to find position/coordinates) but in all honesty I've never worked with unity's Hex grids (only rect and iso ones).

I'll give it a better look when I have a chance.
« Last Edit: March 07, 2023, 10:33:33 AM by Plancksize »