Hello Guest

Author Topic: Box Collider with Character Controller  (Read 9899 times)

Koosmono

  • Newbie
  • *
  • Posts: 3
    • View Profile
Box Collider with Character Controller
« on: March 07, 2012, 06:05:08 am »
I can't seem to find anyone else with this problem so far, so I figured I'd post about it.

My problem is I can't seem to get sprites from 2D toolkit to work properly with the character controller.

I set the sprite collection that I am using for my character to have no box collider. Then I add the character controller and a small script for moving and jumping (from the Unity Reference), which adds its own box collider.

It has a sphere shape with edges that are just on the edge of the sprite, but when I test the game, the sprite will sit a good distance above the platforms. It also collides with other box colliders when it shouldn't, i.e. it won't properly go under elevated platforms, it will hit them from below etc. and no matter how small I make the controller sphere, the collisions are still messed up.

Was wondering if anyone else ran into this problem. The character controller is very helpful, so if I can find a way to use it with 2D toolkit I would be extremely happy. There just seems to be a problem with the box collider it adds to the sprite.

Thanks for any help

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Box Collider with Character Controller
« Reply #1 on: March 07, 2012, 10:07:40 am »
It looks like the character controller keeps the sprite always offset from the ground by a small amount. When you create a sprite collection with the default settings the "small amount" ends up being quite big. You can fix this by increasing the ortho size in your sprite collection, and changing your camera to match (you will obviously need to reposition the objects as everything will be much bigger now).

A size of 10 works much better and there is much less of a gap.

Koosmono

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Box Collider with Character Controller
« Reply #2 on: March 07, 2012, 05:37:46 pm »
I found another solution which seems to be working so far. I lowered the default levels of the "Step Offset" and "Skin Width" fields in the character controller and now everything works fine.

I'll also take a look at your solution Unikron, I just thought I would post what I found since it seems to be another fix to the problem.

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Box Collider with Character Controller
« Reply #3 on: March 07, 2012, 06:15:00 pm »
Thanks for posting your solution :)