Hello Guest

Author Topic: Painting "coin" prefabs with tilemap  (Read 8303 times)

bletalik

  • Newbie
  • *
  • Posts: 3
    • View Profile
Painting "coin" prefabs with tilemap
« on: November 09, 2012, 08:11:45 pm »
I am new to Unity and 2DToolKit. I'm really loving the tool, but I'm having difficulty using the tilemap editor to paint prefabs.

I'm making a basic 2D sidescroller platformer, and I have a basic coin prefab that works as intended when placed as individual objects in the hierarchy.

I want to be able to paint the location of the coins throughout the level using the tilemap editor. I tried dragging the coin prefab into the prefab slot in the data menu of one of my tiles (a placeholder box tile), but nothing happens when it's placed into the game. Although the box can be seen in the scene editor, it is not present in the playtest view.

What am I missing?

Thanks for your help!


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #1 on: November 09, 2012, 08:44:25 pm »
What do you mean its present in the scene view but not in game view?
If its visible in one and not in game view (as I understood it), that implies it might be too far away in the z axis? Try zooming out in the scene view to see where it is in the z axis... If not if you post some screenshots, that would definitely help work out what's gone wrong.

bletalik

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #2 on: November 09, 2012, 10:06:01 pm »
I'm pretty sure the z-axis is 0 for everything, and I'm using an orthographic camera.

In the first screenshot, you'll see that I applied the "gear" prefab to the copper gear tile in my tilemap.

I then placed that copper gear between the grey and white gears in the scene view.

The next screenshot shows the game view, and the copper gear has disappeared.

My goal is to copy to properties from the regular gears (the white and grey ones), to the copper gear that I can place easily using the tilemap.

Does that make sense? Do I need to use the same texture for this to work?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #3 on: November 09, 2012, 10:41:00 pm »
Expand terrainTileMapRenderData - can you find your gear object as a child of that somewhere?

Edit: I mean while the game is running.
« Last Edit: November 09, 2012, 10:44:40 pm by unikron »

agkunz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #4 on: November 10, 2012, 07:34:04 pm »
Hey, working on the same project here-
If you paint a bunch of gears close together, they are lumped together as one object in the object explorer. (Labeled  Chunk 0 0, Chunk 0 1, etc).
If I attach the script to the 'Chunk' item then when you collect one gear the whole 'chunk' of gears gets collected at the same time, we need each one to be individual.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #5 on: November 10, 2012, 11:58:34 pm »
Can you send me a test case showing the issue? Its kinda hard to guess what is going wrong here. (support@unikronsoftware.com)

If not, let me know, and I'll give you some more troubleshooting steps to try work out whats going wrong.

agkunz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #6 on: November 12, 2012, 12:04:08 am »
Maybe I can re-phrase the question.
We have a tile set, we can paint the different sprites on the screen.  What is the correct way to attach a script to each different sprite on the screen (for example in the screen shot you can see multiple coloured gears in the palette, and each will do a different thing)?
I originally had assumed it was by using the prefab option when you select the gameObjectTileMap, hit edit and go to Data.  I select a sprite, attach a prefab gear I built, hit commit and then that sprite disappears off the screen throughout the level (both in design and run time).  If I click edit again it appears back on the screen in design time but will continue to disappear until I remove whatever's in the prefab slot.

Thanks,
« Last Edit: November 12, 2012, 12:46:04 am by agkunz »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #7 on: November 12, 2012, 12:56:18 am »
That kind of workflow should actually work.
The prefab you're attaching has a sprite with the gear on it right?
i.e. when you drag that prefab into the scene, you see the gear at the correct location you've dragged it to, correct?

agkunz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #8 on: November 12, 2012, 01:16:20 am »
Thanks for your quick response, but I was just logging back in to let you know I have figured it out!
This toolkit is pretty cool man, good work!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #9 on: November 12, 2012, 01:57:38 am »
What was it?

bletalik

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Painting "coin" prefabs with tilemap
« Reply #10 on: November 12, 2012, 05:40:40 pm »
It turns out the gear sprite the prefab was using had to be scaled down massively.

When the gear prefab was attached to the tile, it reset the scaling to one. So it wasn't "disappearing", it was just too big that it was completely outside of the camera view.

We just scaled everything to the appropriate size and everything is working great now.

Thanks for all your help and your quick replies!