Feet always above ground

leissler

Member
With Synty characters, it seems that the feet are always a bit above the collider surface of the level.

Image

Has anyone encountered this problem and knows how to fix it?
In the Character IK component, there is a Feet section

Image

But changing the value of the Offset Adjustment doesn't seem to have any effect at all
I tried around several other things, but to no avail, thinking that in such a popular character controller there must be a way to adjust the offset of feet above the ground.

Using UCC latest version and Unity 2021.3 LTS.
 
The Foot Offset Adjustment is what you want. For your character since the feet are in the air have you tried a negative value? That value is used when determining the final foot position:

Code:
m_FootOffset[i] = m_Transform.InverseTransformPoint(foot.position).y - m_FootOffsetAdjustment;
 
When I set the offset to negative values, the character is even higher in the air:
1657192384328.png
Setting it to higher positive values does not get any nearer to the ground, though.
 
I downloaded a Synty character and am noticing the same. I will look into it closer and let you know after I have a solution.

Edit: I've added a new variable that you can add to the CharacterIK component. First declare a new Vector3:

Code:
        [SerializeField] protected float m_HipsPositionOffset;

And change line 691 from:

Code:
 m_HipsOffset = m_ImmediatePosition ? hipsOffset : Mathf.Lerp(m_HipsOffset, hipsOffset, m_HipsPositionAdjustmentSpeed * Time.deltaTime);

to:

Code:
 m_HipsOffset = m_ImmediatePosition ? hipsOffset : Mathf.Lerp(m_HipsOffset, hipsOffset, m_HipsPositionAdjustmentSpeed * Time.deltaTime) + m_HipsPositionOffset;
 
Last edited:
I tried out your fixes and unfortunately they don't work.
1657232025111.png
On the right you can see the new offset field. Whatever value I put in there, it will have no effect at all. I tried positive and negative values.

Here's the line of code in my Rider
1657232145406.png
It was line 690, though, not 691 in CharacterIK.cs
 
Hmm, I wonder if anything else has changed. When I try a value of .002 for Synty characters it looks good:

1657260973346.png

But lets try this: move that addition two lines down:

Code:
 m_HipsPosition.y -= m_HipsOffset + m_HipOffset;
 
Wait, it does work now (EDIT: the very first change you proposed). I had no camera set up in my tests!
Why is the IK calculation dependent on the existence of camera components?
 
Last edited:
Ok, I can confirm some serious dependency issue here. When you create a character but your character (third person) doesn't have a Camera Controller component, the character will not accept input and the IK component places the feet above the ground.
As soon as you add a Camera Controller, input works and IK for placement too.
This makes character control inherently dependent on using the character controllers camera system, instead of, e.g., Cinemachine (yes I know there is a Cinemachine integration).
Is it possible to fix these dependencies?
 
I'm glad you got it working! There is a LookSource which affects where the limbs are positioned. You could inspect the LookSource values to determine the differences and then create a new ILookSource component that returns those same inspected values.
 
Yes, that would be a cleaner solution. Would it be too much to ask to integrate these two changes (m_HipsPositionOffset and ILookSource) into the next version of Opsive controllers?
 
The HipsPositionOffset is in :) The ILookSource change depends on what camera you are using so probably won't be in the next update. I can add it to my list of things to look at but it'll probably be quicker if you just take a look at what the values are and make a subclass of the ViewType that you are using with those values.
 
Sounds fair enough. The HipsPositionOffset would make the system more flexible and Synty characters are pretty popular nowadays.
Anything that loosens the dependency between camera/view and character controller would also strengthen the system.
It would be great if a newly created character would also react to input and be correctly positioned, even without a looksource. Maybe just adjust the code for the no-looksource case?
 
Last edited:
I dug through the source code a bit. To make it work without an ILooksource (like the Camera Controller) you could have some default/dummy ILooksource implementation that just makes the character look forward.
My guts tell me that this would just cost a few IF clauses at the right places in the code. Maybe even only some more if (m_LookSource != null) ... else ... statements somewhere.
The Input also seems to depend on the Looksource somehow.
 
You could add the LocalLookSource for that use case. The character should always have a look source, whether it is player-controlled, AI agent, networked, etc. The input does not use the look source.
 
Why does the input then not work without a View Type entry in the Camera Controller component?
What would I have to do to use a LocalLookSource? Add a Local Look Source component to the camera? And then what?
 
Last edited:
Why does the input then not work without a View Type entry in the Camera Controller component?
The input doesn't know about the view types but the controller isn't updated unless it has an ILookSource. You just need to add a LocalLookSource.

What would I have to do to use a LocalLooSource? Add a Local Look Source component to the camera? And then what?
You add it to the character. If you are using the character manager it will automatically add this for AI agents.
 
That works in the sense that the characters' feet are now on the ground and it's controllable by input.
It does look pretty funny, because the character is looking toward his feet (setting the body IK sliders to zero is the right solution for that?) and walking to the left/right makes the character walk in a circle all the time, like a cat chasing its own tail.
As a Look Transform, I set the character itself. But the target field is empty.
 
The character is looking at themself because of the Look Transform. You should set it to a value in front of the character if you want the character to look ahead of the character.

If your character is controlled by input then you should be using the camera controller so it sets the proper look source values. The LocalLookSource is mainly for AI which is moved with pathfinding. Alternatively if you want something custom you could implement your own ILookSource.
 
I think a custom ForwardLookSource could be the best solution here to use any external camera system. That was the whole point of this thread: To give users the choice of any camera system, without having to use the Camera Controller component.
I'll try to implement it, which shouldn't be rocket science.
 
Top