3
\$\begingroup\$

I'm moving my CharacterController with the Move() method and for some reason it still steps on colliders even though its Step Offset is 0.

Here's how the game looks:

  • Every objects' root is at Y = 0, so their colliders' center is offsetted.
  • the floor is made up from tiles, with QuadColliders.
  • there stairs have just a BoxCollider
  • the player got a CharacterController

enter image description here

Here are the components:

CharacterController, stairs' collider, and the floor's collider, where the floor itself is scaled to (2, 2, 1):

enter image description here

I've checked the collisions with OnControllerColliderHit() and:

  • After hitting play the Y is 0, as it should be.
  • After moving a bit, without colliding with anything the Y changes from 0 to 0.079.
  • Then if I start running towards a BoxCollider, after some time it steps on it incrementally under half a second.
    • (The collider has a 0.8 height, so controller's Y changes to 0.8)

I'm a bit lost, thanks in advance for all the help! :)

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ Try playing around with your skin width. \$\endgroup\$ Commented Apr 27, 2022 at 0:56
  • \$\begingroup\$ @Evorlor in what ways exactly? :| The docs says that having it around 10% of the radius is good. It's 10% right now. \$\endgroup\$ Commented Apr 27, 2022 at 12:03
  • \$\begingroup\$ What are you exactly trying to achieve? How are you moving your character? I may be wrong, but I think the problem here may be your character controller settings. \$\endgroup\$ Commented Apr 27, 2022 at 23:53
  • \$\begingroup\$ @C.G.Yeudiel I call characterController.Move() with a Vector3 whose Y is always zero (I work with Vector2-s in game logic, so I just convert it before passing it to Unity) My goal is to make my character's Y stay at zero :D \$\endgroup\$ Commented Apr 28, 2022 at 5:59
  • \$\begingroup\$ @Tudvari Hmm, alright, it may be a mix of many different variables. It's hard to tell without code, even though I don't think the problem comes from the code itself. In fact, I think this is expected behavior (except for the stair). According to the docs, the Step Offset can affect the way your character controller behaves, and it doesn't recommend using a value lower than 0.1 (0.4 for a 2 meter tall humanoid). Your character is 3 meters tall so maybe that's the issue. \$\endgroup\$ Commented Apr 28, 2022 at 19:19

1 Answer 1

2
+50
\$\begingroup\$

The official api of unity has a vague explanation of each parameter. After testing I got the relatively correct meaning of the parameters.

enter image description here

In this collision situation, as long as the hemisphere of the capsule is higher than the upper plane of the box, it will cross the box. Skinwidth will expand your capsule body, The capsule is raised due to the collision between the capsule and the ground, So it will cross the box.

So in fact, the height that the capsule body can cross is the larger of the value determined by step offset and physical properties.

The maximum height your capsule can cross is 0.88(capsule's radius + skin width)(>0.8), What you describe is expected performance.

Suggestion:

Reduce the radius of the capsule to make it fit the character better. I think (0.5~0.6) will be fine.

edit:

  1. Why use radius: When the collision occurs on a spherical surface, the force vector points to the center of the sphere, It will bring an upward component, causing the capsule to lift.
  2. Why 0.5-0.6 would fit better the character: There is no mandatory standard. But the character's collision box should fit as close to the torso as possible, The example in your picture looks a bit too large, which leads to a series of problems that are not intuitive. Your question is one of them.

Sorry I'm not a native English speaker, some words are used incorrectly, have been re-edited, hope it helps.

\$\endgroup\$
3
  • \$\begingroup\$ Could you rephrase it a bit? What is exactly the surface portion? I guess 0.88 is radius + skin width. Why did you use radius? And why do you think 0.5-0.6 would fit better the character? I have a higher than visual size so it can be more easily :| \$\endgroup\$ Commented Apr 29, 2022 at 18:50
  • \$\begingroup\$ Thanks for the edit, it's clearer now! :) Good job on figuring out this issue, I reduced the radius thus lowering the height of the hemisphere and now it works! :)) Thanks again! \$\endgroup\$ Commented Apr 29, 2022 at 19:46
  • \$\begingroup\$ For all who's interested: I posted this issue on Unity's forums, maybe they will do something about it: forum.unity.com/threads/… \$\endgroup\$ Commented Apr 29, 2022 at 20:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.