I’m having trouble trying to make my character align to the angle of the ground he is standing on.
My method is to use a LineTraceByChannel pointing down to get the ground angle where the character is standing and adjust the character rotation accordingly. It’s working very well except in the specific condition of being near a steep angle change in the ground.
What happens is the line that is traced points to the character “down vector”, so when the character rotates the line then hits the ground where the angle is different, so the character rotates back and it gets the previous angle again, so it rotates again, and creates a loop that makes the character rotate back and forth violently.
I tried then making the line always point straight down, regardless of the rotation of the character. This was much better, because now the character doesn’t swing back and forth, but it creates a different problem: depending on the angle change in the ground, the character might look like he is floating.
And there’s a second (smaller) issue that happens in both cases: if the character lands on a slope and doesn’t move, the rotation will make it’s feet sink into the ground. If the character moves this is corrected because the capsule collision corrects it, but if you stay still as soon as you land, the feet will sink in. But this is a smaller issue that I’m willing to live with.
All this happens because the pawn in the third person character has the pivot point set in the center and not the floor. If it was in the floor the character would rotate around the floor point and all these issues wouldn’t happen. But it’s impossible to move the capsule, so the pivot point has to always be in the center of the character. Knowing this, is there a work around? Would really appreciate some help.
Below I have illustrated the issue so it’s made clearer:
With line pointing to character’s “down vector”:
With line always pointing straight down (much better, but still has issues):