Unity-Technologies / 2d-extras

Fun 2D Stuff that we'd like to share!
Other
1.54k stars 342 forks source link

Prefab brush keeps painting prefabs in the same tile #242

Open javiarias opened 3 years ago

javiarias commented 3 years ago

Whenever I try to draw a "line" of walls the brush will always spawn more prefabs than needed. I managed to reproduce this semi-consistently by flipping back and forth between two tiles (and sometimes just moving the mouse inside a single tile).

I'm using version 1.6.1-preview (or at least, that's what shows up on the Package Manager), with Unity 2020.1.7f1.

ChuanXin-Unity commented 3 years ago

Could you share a screenshot of the Prefab instances in the Inspector window and in the SceneView painted by the Prefab Brush? Also, if you can, please do share a picture of the Prefab Brush Inspector found at the bottom of the Tile Palette. Thanks!

vladderb commented 3 years ago

I'm trying to reproduce this in the current master version, but the bug does not repeat. I think this bug is only available in the version for unity 2020. I will now check it out and fix it if I can.

vladderb commented 3 years ago

Hmm, at first I really thought I had found this bug, and then I realized that my fork was just an old version of the branches from the original repository. At the moment I cannot reproduce this bug on the master branch using unity 2020.1

javiarias commented 3 years ago

Sure thing! The prefabs are simple ProBuilder shapes image image

As for the brush, here it is image

I had to mess with the settings for it to work properly, as it seems a "z position" of 0 wouldn't allow me to place prefabs "above" already occupied tiles (shown here) image

After changing up the brush a bit i discovered that with an anchor of {0.5, 0.5, 0} all these problems vanished. Problem is, that kind of ruins my whole map :(

ChuanXin-Unity commented 3 years ago

It looks like the Anchor values are causing the issue, as using (0, 1, 0) would mean that the GameObject is instantiated at the +(0, 1, 0) cell, while we are checking for the relative (0, 0, 0) cell for duplicates.

We will investigate and see how this can be handled, thanks!

ChuanXin-Unity commented 3 years ago

Hi, I have updated the PrefabBrush at https://github.com/Unity-Technologies/2d-extras/tree/prefabbrushanchor , which will be added to the next Tilemap Extras package (1.6.3-preview). Let us know if this works out for you, thanks!