CharacterMovement component has a Walkable Floor Angle value. How does character determine angle of floor below it? Is there a way to get angle of floor from this somehow?
Walkable Floor Angle is used to determine what degree slope a Character can walk on without entering a falling state, up to but not including 90 degrees. By default, this is set to just under 45 degrees. You can read more about making adjustments to that value and to overriding that value for other actors and surfaces here:
To determine angle of floor below a Character, a capsule trace is done straight down from Character Capsule. You can find result in CharacterMovementComponent > CurrentFloor. If capsule trace fails to find a walkable angle, a line trace is used as a fallback.
angle is determined by normal of impacted surface. A flat platform has an angle of 0, and a vertical surface has an angle of 90 (which cannot be walked on). This is updated only during Character walking movement.
So to find angle of floor below Character as it walks, get Character Movement’s Current Floor value (a struct). You can then Break FindFloorResult to get several Booleans, float values for distance on capsule and line traces, and Hit Result. Hit Result can then be broken down to find its Impact Normal.
Thank you so much for this!
Although it works it has one small problem.It only outputs positive numbers so it rotates correctly only for left side of a slope but not for right one.Is there a way for system to understand when we are ascending or descending or a trick to get negative rotation when he is on right side (of a slope) so it can work on both cases as intended?
Hey ,
I mentioned to you in our PM conversation that you could derive pitch of floor by getting Impact Normal and making a rotation from that. While there is more information in Impact Normal, what you need is actually much simpler to attain.
Instead of Impact Normal, use Hit Actor result and Get Actor Rotation (in 4.5.1, you’ll probably need to disable Context Sensitive to find it in context menu… a known issue). Then, for a 2D game like yours, Break Rot and get Pitch value, which should have a positive or negative value depending on which way floor actor is rotated.