Hello Guest

Author Topic: Parameters for instances of prefabs in tilemaps?  (Read 4928 times)

fornit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Parameters for instances of prefabs in tilemaps?
« on: August 11, 2015, 11:20:13 am »
Is it possible to pass some kind of parameter on to prefabs or attach information to instances of tiles?

I want to use tiles for trigger plates, levers etc. to open doors or make walls disappear (door and wall prefabs, not part of the static level) or to trigger traps.
To do that, i would need to connect the trigger to the object it is supposed to activate. The best solution i can think of right now is use individual tiles for each trigger/object pair, but that is really ugly and can get out of hand quickly with bigger, more complex levels.
As far as i can see the tile info string and ID is per tile type, not per individual tile. Is there any way to pass info to the trigger prefab through the tilemap?

edit:
could i use an extra layer with transparent tiles? So i can "mark" the trigger and triggered object with the same "parameter tile". At least that way i only have one extra tile per trigger/object pair. Also, i could make them semi-transparent in different colors so that its visible in the scene view which trigger belongs to which object.
« Last Edit: August 11, 2015, 02:05:52 pm by fornit »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Parameters for instances of prefabs in tilemaps?
« Reply #1 on: August 13, 2015, 09:55:56 am »
Hi there,

The transparent tiles is a valid option - I've used something similar in the past, even use it in the tilemap demo to mark scene boundaries that are only visible in edit mode. The tiles themselves don't need to be transparent, they can be on a layer that has graphics unticked in the layer settings. You could set up a bunch of sprites indicating the different states and wiring up details that you can then draw in the tilemap editor into this layer. Remember the sprites don't have to be full res, just tiny sprites (eg. 8x8) will do the job as all you need to signify is one letter and a colour to link things up.

The other option is to simply edit the prefab properties after you commit - tk2d will try to retain the prefabs themselves so they don't get recreated every time you edit and commit and the properties will be retained.

Personally I'd prefer #1 as its far more visual and you can create all sorts of complex relationships programatically and use tk2d just to store light metadata.

fornit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Parameters for instances of prefabs in tilemaps?
« Reply #2 on: August 14, 2015, 01:57:13 pm »
I am afraid you have to eloborate.
the longer I think about your post he more ambiguous it gets  :o

My idea was to essentially use the tileID as the primary information storage. So i set up a tile for every single piece of information (connections between objects for example but also IDs for texts on signs, books etc.). The color of the tiles is just for the user to easily identify connection between tiles.

Your posts reads as if the color is carrying the information. Do you use a color channel to transport information and the links are dependent on the color instead of the tileID?

edit: I'd like to keep my solution usable both in the 2d toolkit editor and the Tiled map editor unless an incompatible solution is vastly superior.

Oh btw, I am writing playmaker actions for the relevant functions. There aren't any official playmaker actions for the tileset functions, right? Are those planned for future toolkit releases? If so you can have mine when i am done and you just polish them for the official release. Or i can just post them in the forum. Or not at all. Whatever you prefer  :)
« Last Edit: August 14, 2015, 02:35:10 pm by fornit »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Parameters for instances of prefabs in tilemaps?
« Reply #3 on: August 17, 2015, 11:49:53 am »
No no the colour stuff is just to visually differentiate and associate connections. We have the same idea, using tileIds are information storage. This will work anywhere, tiled / tk2d map editor :)

Playmaker actions - please post them on the forums and I'll integrate.