Hello Guest

Author Topic: Mesh Collider not seeming to work  (Read 4337 times)

ErebosGames

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Mesh Collider not seeming to work
« on: April 09, 2013, 07:57:48 pm »
Update:
I noticed that when in the sprite batcher, the ground is now a mesh collider, instead of individual box colliders. I read that mesh colliders cannot collide with each other unless they are convex, which the ground sprite batcher cannot be. So, is there a way to use the sprite batcher and have a mesh collider on another object, such as a rock?

Bonus unrelated question still applies: why is gravity so 'fast'? How would I make the crates fall slower?

Original:
Hello,

I'm fairly new to Unity and just started using 2D Toolkit this morning, so this might be an easy fix - but I did spend about 30 mins researching before deciding to post here!

I'm going through the walk-throughs in the documentation and I made a scene that looks like the one at the end of this tutorial:
http://www.unikronsoftware.com/2dtoolkit/doc/tutorial/using_the_static_sprite_batcher.html

I created the polygon collider on the rock, and the box trimmed collider on the crate. I added a physics rigidbody component to both the crate and the rock. When I hit play, the box falls onto the ground as it should, but the rock falls straight through. From doing some research, I saw that maybe I needed to select the 'Convex' option on the mesh collider. I tried that, and after hitting play again, the same thing happens. BUT, when looking back at the convex option, it has been deselected! As soon as I hit play, the convex option deselects itself.

Bonus unrelated question: gravity seems super fast, as in the crates and rock fall very quickly. How would I go about adjusting the speed of gravity?

Here is the inspector for the rock:


Here is what my scene looks like exactly:


Here is what the rendered scene looks like: (notice how the rock is not there - it just falls straight through the ground objects)
« Last Edit: April 09, 2013, 08:05:33 pm by ErebosGames »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Mesh Collider not seeming to work
« Reply #1 on: April 10, 2013, 12:34:28 am »
1. Gravity - this depends on how big your sprites are physically. If you're using the default sprite collection settings, then the sprites are probably going to be too small. Edit gravity in the physics manager to suit the settings, or alternatively increase the size (in sprite collection settings, increase ortho size). ortho size = distance in meters from top of screen to middle of screen.
Ortho size = 1 => top of screen to bottom of screen is 2 meters. You can imagine how fast something would drop over that distance without any drag. Increase it to 10, and then the distance is now 20 meters.

2. The rock is actually convex, so if you made the rock convex you could just use that. Alternatively, you could construct a compound collider using multiple box colliders. The only downsides are -
  i. You can't set this up in the tk2d editor (not yet anyway)
  ii. As a result you can't animate them