I have a scene where there is a muti-level stair.And when I go up,the character is moving up shaking not smoothly.As camera is binded with character, the camera is like so.How to avoid it?
Hey, could you provide some additional information?
Graph type you’re using?
Movement system you are using?
Collider with rigid body, or character controller?
Maybe even a screenshot of the staircase you’re having issues with + visible graph ofc.
Could you also provide a screen shot of the collider that the staircase uses, + the character is setup, character controller or capsule collider
Is there a solution about smooth movement?Or I should use smooth slope instead of stairs？
Alright, I’ll try to explain a little bit here how unity works. Since this choppy movement doesn’t come from A* but rather how physics work.
On your staircase you’re using a a non convex mesh collider. This basically means that the collider will be identical to the mesh, aka all polygons are considered a collision. So your collision mesh has the little step components build in.
Second to that you are using a normal capsule collider with rigid body. Again also an acceptable use case. It’s a great way to have physics working together or against your character. Many people prefer this over the alternative solution of character controller.
However capsule collider with rigid body is a more barebones approach and doesn’t handle steps very well. Rather it doesn’t handle it at all. It just pushes the collider until somehow it has enough force that the physics engine starts cutting corners.
There are 3 possible solutions. And depending on other game mechanics and features you want to use you’ll have to pick one.
Set the mesh collider of the stairs to convex.
Making the stairs convex will make the collier a slope rather than a staircase. This is a very common solution. However if you ever want to include foot IK solutions. You shouldn’t use this solution.
Replace the rigid body and capsule collider with character controller.
The character controller is a prebuild system included with physX. It’s a great system to add simple movement without much work of the developers. It especially handles steps really well. Read more about the character controller here: https://docs.unity3d.com/Manual/class-CharacterController.html
Write custom step detection system.
If you don’t want to use the character controller. You can work on a step detection system. To handle the step effects. There is multiple ways this can be achieved. But will require some research.
Hope that helps
OK,I will try it later.Thanks for your detailed reply:+1:
Today,I have done a test about your suggestion.
About solution one,it improves greatly,only the area where stairs contact with lower or higer plane still shakes.
Solution two,I change “Skin width” parameter,but it’s improvement is not so good.Pehaps as my radius is small.
And solution three,I don’t try it.I think it might be hard and time-consuming to me~~
I will use solution one and try to searching for optimization method or if you know it.
Nice to hear that you have some improvements already. For the character controller usually the Step offset is the value you want to change. Note like it says in documentation. Can not be larger than the height of the character.
Ps. You can also combine solutions 1 and 2.
I Misread the parameter…The “Min Move Distance” parameter do have a little improvement but still shaking.
Is there anything else to do about solution 1?Of course,the result is almost satisfying so far.
Could you show a video of this shaking?
If you want smoother camera movement I would suggest to not couple the camera position to the character directly, but instead use a smooth camera following script. Many unity tutorials have examples of such scripts and I think there are even some included in the standard assets.