Colliders and Collision

Hai Folks,
I am newbie in unity, i have one question.
Now I am trying to collide my player with enemy.
The problem is: after adding box Collider to my player his running is not smooth as expected,
after removing box Collider his running and actions is good.,
i am using joystick controls for moving player.,

Thanks!

Hi there

Without knowing your exact scenario I can only guess, but I suspect your player is now colliding with the ground differently. If he already had a collider attached you’ll see altogether funky behaviour, as you can only have 1 collider per object. If not (maybe the player is just held above the ground by forcing him to stay at the same y or something) then its probably just the box collider hitting the ground.

You have a few options depending on the behaviour you want:

  • You could try making the collider smaller (look in the inspector) so it doesn’t touch the ground - if the object is selected there is a visualisation of how big the collider is so you should be able to see if it intersects the ground.
  • You could create layers for your players, enemies and ground (notice the layer option in the inspector - you’re going to use it a lot in unity!). Then inside the physics properties for your project (check the edit menu) you can edit the collision matrix (fancy word for tick boxes) to say ‘things in the player layer shouldnt collide with things in the ground layer’
  • If the box is just sliding gently along the ground, you could give it a physics material with friction set to 0, so it slides perfectly

Hope that helps.