Hello Guest

Author Topic: Collider Issue in 4.3  (Read 15425 times)

sniperjp02

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Collider Issue in 4.3
« on: November 26, 2013, 05:18:15 am »
Hello all,

I am using 2D Toolkit 2.3 with Unity 4.3 and I keep running into an odd issue.
Sometimes when I edit a texture I see 2 different types of "weirdness".

I am using polygon colliders for most game objects and box colliders for simpler objects.
I see these issues when I edit a texture externally (update graphic in Illustrator and export using Photoshop to the Asset folder).

I would like to know the proper process for updating textures as I see the following:

1. If I change the dimensions of the original texture the sprite will have the new texture but the collider will still have the old dimensions. When I edit the collider in the collection everything looks good. When I go back to the editor I can see the collider does not indeed match the dimensions of the sprite.

2. I randomly see huge performance drops and after investigating I found that for some reason my game objects will randomly duplicate the colliders attached to them. Sometimes a single object will have over 30 colliders.

I appreciate any insight on these problems and if I am doing something wrong I could really use some advice on what the proper process is. This has happened at least 3 times now and it is very time consuming to repair the state of my objects.

Thanks,
Jacob

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Collider Issue in 4.3
« Reply #1 on: November 26, 2013, 09:52:19 am »
Are you using 2d or 3d physics?
1. How have you configured the collider in the sprite collection editor?
2. Is this due to changing the textures externally?

sniperjp02

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Collider Issue in 4.3
« Reply #2 on: November 27, 2013, 04:31:14 am »
Thanks for the reply unikron.

I am using 2D physics and this project was originally created in 4.3 with 2D presets selected.

1. I was originally using the 2D ColliderGen asset to auto-trace the sprites and then hand tweaked them. After seeing this issue a few times I stopped using it to see if it would happened again, which it has. I am creating the polygon colliders by hand and using custom box colliders on simpler objects now. I am pretty sure only the polygon colliders are being duped.
2. Yes I am changing the textures externally and then opening the sprite collection which contains the changed texture and editing the collider. Sometimes I change the texture while the project is open in Unity and other times Unity was closed.

Should I only edit textures with Unity open?
Have you seen anything like this before or do you think it is an issue with 4.3?

I will try to find a reproducible case if I can.

Thanks again,
Jacob

sniperjp02

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Collider Issue in 4.3
« Reply #3 on: November 27, 2013, 05:10:57 am »
Ok, so I seemed to have found a reproducible case for the collider duplication issue.

Steps:

1. Create a Sprite Collection.
2. Add texture (I use point filter, 2D Physics, and have 1x and 2x sprites for settings).
   2a. Create polygon collider and commit.
3. Create a new tk2d sprite using the new sprite.
4. Rename and add a 2D Rigidbody and create a prefab from the object.
------Up to here everything is fine------
5. Create new texture in Photoshop and overwrite the texture and @2x version in the asset folder (with Unity open).
6. Open the Sprite Collection and click commit, the collider will be duped at this point for all sprites in this collection that are in the scene.

Normally I would edit the collider in step 6 but I found that is not necessary to reproduce this behavior.

I assume this behavior is not expected.
For now I will try to avoid editing textures once they are in the project.

Please let me know if the steps I take are not "standard" or if I should be doing something else.

Thanks,
Jacob


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Collider Issue in 4.3
« Reply #4 on: November 28, 2013, 11:04:44 am »
This is expected use case and should work properly. It is likely a bug - I will investigate this. Thanks for the comprehensive repro case.
Edit: I've been attempting to reproduce this and I don't seem to be able to. Would it be possible to email a repro project where its at step 5? Should be able to catch it pretty easily then.
« Last Edit: November 28, 2013, 11:56:49 am by unikronsoftware »

sniperjp02

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Collider Issue in 4.3
« Reply #5 on: November 28, 2013, 05:45:41 pm »
Hello unikron,

I was unable to reproduce this in a clean project.

After I added the 2D ColliderGen plugin to the project I was able to reproduce it.
In my other project I still had 2D ColliderGen added but was not using it.
I will remove it from the project for now and contact support for that plugin.

Thanks for the help,
Jacob

TheMightyGit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Collider Issue in 4.3
« Reply #6 on: December 04, 2013, 10:36:43 am »
This is expected use case and should work properly. It is likely a bug - I will investigate this. Thanks for the comprehensive repro case.
Edit: I've been attempting to reproduce this and I don't seem to be able to. Would it be possible to email a repro project where its at step 5? Should be able to catch it pretty easily then.

I get duplicated 2D Polygon Colliders on my main spaceship every time I hit 'play'. Without fail. As far as I know I'm not doing anything exotic. It's just a prefabbed tk2d sprite with an animator and 2 attach points (one of the attach points has a tk2d sprite in it).  However, it also happens to the baddies, but far less often (they tend to be inactive in edit mode, tho).

As yet I cannot identify the difference between when the excess ones get added to the ship and baddies.
« Last Edit: December 04, 2013, 10:57:22 am by TheMightyGit »

TheMightyGit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Collider Issue in 4.3
« Reply #7 on: December 04, 2013, 10:43:02 am »
I get duplicated 2D Polygon Colliders on my main spaceship every time I hit 'play'. Without fail. As far as I know I'm not doing anything exotic. It's just a prefabbed tk2d sprite with an animator and 2 attach points (one of the attach points has a tk2d sprite in it).  However, it also happens to the baddies, but far less often (they tend to be inactive in edit mode, tho).

As yet I cannot identify the difference between when the excess ones get added to the ship and baddies.

Setting the initial sprite to one with a 'force none' collider works around the issue.
« Last Edit: December 04, 2013, 10:57:32 am by TheMightyGit »

TheMightyGit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Collider Issue in 4.3
« Reply #8 on: December 04, 2013, 10:49:17 am »
Setting the initial sprite to one with a 'force none' collider works around the issue.

Odder still, now when I switch back to an initial sprite with a collider - it still works properly!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Collider Issue in 4.3
« Reply #9 on: December 04, 2013, 10:59:11 am »
Very odd indeed - there could be some weird case I'm not handling properly. Please let me know if you find out whats causing this.

TheMightyGit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Collider Issue in 4.3
« Reply #10 on: December 05, 2013, 05:12:22 pm »
Very odd indeed - there could be some weird case I'm not handling properly. Please let me know if you find out whats causing this.

It was fine for a while, now I've got 20+ 2D Poly Colliders on my ship again. Was fine all yesterday, didn't notice when or why it started to happen again.  Will try and keep a sharper eye out.

TheMightyGit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Collider Issue in 4.3
« Reply #11 on: December 05, 2013, 05:50:32 pm »
Very odd indeed - there could be some weird case I'm not handling properly. Please let me know if you find out whats causing this.

It was fine for a while, now I've got 20+ 2D Poly Colliders on my ship again. Was fine all yesterday, didn't notice when or why it started to happen again.  Will try and keep a sharper eye out.

Ahh! Got it. After I 'commit' my sprite collection, all subsequent 'play' presses cause an extra 2D Poly Collider to appear.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Collider Issue in 4.3
« Reply #12 on: December 05, 2013, 06:34:36 pm »
Can you send me a repro of this? I haven't been abel to reproduce it on my end. support at unikronsoftware.com

jinyangnet

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Collider Issue in 4.3
« Reply #13 on: December 09, 2013, 02:49:18 pm »
I am also the same problem , add more than 100 PolygonCollider2D...

Had no choice but to Modify UpdateCollider ()  stop continue to increase PolygonCollider2D
PolygonCollider2D [] poly = gameObject.GetComponents ();
if (poly.Length> 0) return;


Hello all,

I am using 2D Toolkit 2.3 with Unity 4.3 and I keep running into an odd issue.
Sometimes when I edit a texture I see 2 different types of "weirdness".

I am using polygon colliders for most game objects and box colliders for simpler objects.
I see these issues when I edit a texture externally (update graphic in Illustrator and export using Photoshop to the Asset folder).

I would like to know the proper process for updating textures as I see the following:

1. If I change the dimensions of the original texture the sprite will have the new texture but the collider will still have the old dimensions. When I edit the collider in the collection everything looks good. When I go back to the editor I can see the collider does not indeed match the dimensions of the sprite.

2. I randomly see huge performance drops and after investigating I found that for some reason my game objects will randomly duplicate the colliders attached to them. Sometimes a single object will have over 30 colliders.

I appreciate any insight on these problems and if I am doing something wrong I could really use some advice on what the proper process is. This has happened at least 3 times now and it is very time consuming to repair the state of my objects.

Thanks,
Jacob

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Collider Issue in 4.3
« Reply #14 on: December 10, 2013, 02:46:12 pm »
I've updated the code for the next version - it should detect this a lot better. Let me know how that goes once its released.