Replies: 2 comments
-
I think it would work better if you split up your movement in a component that runs parallel to the slope (i.e. where the movement is not affected by the slope) and a component that moves into the slope: In this plane, the movement (m) is projected by CharacterVirtual onto the slope and becomes shorter (p = m - m dot n * n). In order to move in the direction of the camera, you'd need to scale that movement component up by 1/cos(alpha) = 1/p dot m (or scale the parallel component down by cos(alpha)). Obviously this causes problems if the slope is vertical, so you'd need to handle that. When moving away from the slope you need a different scale vector as you will be moving faster rather than slower. The main advantage I see here is that you'd be moving horizontally only, which means that the character would not have the tendency to leave the floor. Disclaimer: I didn't test the actual math so beware of mistakes. Note also that the projection mentioned above is a simplification of what the CharacterVirtual actually does, it can handle being in contact with more than 1 slope (imagine walking in a V) so a single ground normal cannot fully represent what the character is going to do (see: CharacterVirtual::SolveConstraints). |
Beta Was this translation helpful? Give feedback.
-
Interesting. I will take a look at that to see what I can incorporate but it sounds like what I want to achieve. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I'm trying to get a character setup in Jolt. I've got the basics copied from the sample but I'm stuck on one thing. I want my character to walk up slopes without the angle of the slope causing a divergence in the player input and the result. For example in my little test level my camera has my character pointing directly towards a specific spot on top of the hill:
However if I hold W (without changing the camera or anything) the player ends up to the left of the desired location because the angle of the slope impacted the velocity:
Is there a way to have the character align velocity with the ground as it moves? I've tried manipulating the movement input based on the camera and ground normal which I've had success with when writing a character controller from scratch in Unity, but it causes the player to pop off the ground at times, so I don't think this is quite correct for how Jolt's ExtendedUpdate works internally:
Is there another way? Maybe something in the character listener callbacks?
Beta Was this translation helpful? Give feedback.
All reactions