Topic was automatically imported from the old Question2Answer platform.
Asked By
godotlearner
When player climbs on a wall, the forward direction may not be perpendicular to the wall plane, which will result in weired animation. I want adjust the character’s rotation at the moment FSM changes to climb state. I tried a few ways but none of them works including:
change the basis.z with -1 * collision normal
look at the collision point (I know why this fails because if the forward direction is not perpendicular to the wall the look_at won’t work. If it is perpendicular there’s no need to look at)
I’m new here and a newbie to gamedev. I’m very grateful if you are willing to offer some help.
this works perfect when climbing on a cube whose faces are not bevel.
What about bevel cases where the y component is no longer Vector3.UP
Someone on Reddit gives me the solution, here is the code:
var z = -1 * normal
var x = normal.cross(Vector3.UP).normalized()
var y = z.rotated(x, -PI/2)
character.rotation_helper.transform.basis = Basis(x, y, z)
The point is getting x by z-up plane
and getting y axis by rotating z around x by -90 degree