Hello Guest

Author Topic: Problem with polygon colliders  (Read 6368 times)

Udorn

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Problem with polygon colliders
« on: February 16, 2013, 05:55:11 pm »
Hi,

I have a problem with polygon colliders. My sprites do overlap, if I use them. If I use boxed colliders instead of it everything is fine. I found in a different thread, that I should check convex, but that doesn't help in my case.

I'm using the newest 2D toolkit version from the Asset store (probably one week old) and in the unity forum are a few pictures describing my problem: http://answers.unity3d.com/questions/400328/strange-rigidbody-behaviour.html

Does anybody know, how I can use polygon colliders with my sprites?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Problem with polygon colliders
« Reply #1 on: February 16, 2013, 06:04:03 pm »
It shouldn't make any difference what version of tk2d you're using - the mesh collider system still uses the same Physx collision code. The first image is missing in your post.

How is the hierarchy set up on the rigidbody? Are they both convex? Have you tried it without the trigger rigidbody?
Also, what kind of camera are you using? Try the tk2dcamera (its much much larger) to see if its a sensitivity thing.

Its hard to tell whats gone wrong just from the pics there, but its definitely possible to do this.

Udorn

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Problem with polygon colliders
« Reply #2 on: February 16, 2013, 06:31:08 pm »
Thanks for your fast answer. :-) Yes, it's strange, sometimes the first image is visible and sometimes not. Is the direct link visible for you?



The temp in the url doesn't sound good. ;-)

The triggers are just empty GameObjects with box colliders and "Is Trigger" checked. I've added no rigidbodies to them. Only the two ship-sprites have rigidbodies. Both ships are using the same sprite from the sprite collection and both of them are convex.

Currently I'm using a standard orthographic camera with the z axis pointing into the scene. Tomorrow I will try the tk2dcamera as you suggested.
« Last Edit: February 17, 2013, 08:55:19 am by Udorn »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Problem with polygon colliders
« Reply #3 on: February 16, 2013, 08:05:20 pm »
Nope, the direct link isn't visible either. FWIW, I'm using Chrome on Windows.

Udorn

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Problem with polygon colliders
« Reply #4 on: February 17, 2013, 09:27:09 am »
Ok, now I have integrated the tk2dcamera and the ships do still overlap.




Btw the documentation of the tk2camera could be a little bit more exhaustive. ;-) In the first moment I was a little bit lost, until I realized, that I have to think in pixels and not in "units" anymore.

Are there some best practices documented somewhere on how to support the different resultions?

Update: Ok, the resolutions are clearer now, I learned that i have to press play to get the view adjusted for the changed resolution. Is the tk2camera always pixel-perfect, or is there also a zoom factor somewhere? Changing the size parameter seems to not change anything.
« Last Edit: February 17, 2013, 12:20:37 pm by Udorn »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Problem with polygon colliders
« Reply #5 on: February 17, 2013, 08:00:48 pm »
Docs -
http://unikronsoftware.com/2dtoolkit/doc/reference/tk2dcamera.html
http://unikronsoftware.com/2dtoolkit/doc/tutorial/tk2dcamera.html

Its always pixel perfect, unless you want to scale it differently using an override. The "press play to see update" thing is temperamental. Its meant to be instantaneous, but sometimes Unity doesn't call the function immediately.

With different resolutions, it depends what you plan to achieve with your game. Add an override, and you can tell it to fit vertical, horizontal, visible, and so on. You build your game at "native resolution" and the camera scales itself for display on the other resolutions based on your override choice.