As you know, in UPBGE , the character Physics makes the character slippy . I want the character to stick (or better, tune it on a scale of 0-100) to its place even if the ground is not flat.
I want to be able to derivate the Vector that will “cancel” the ground.hitNormal and introduce it into the Motion actuator
this code doesn’t work as the character’s Orientation keeps having effect on the character motion even if idling (keep sliding down , up, right, left)
woc = player.getAxisVect(ground.hitNormal)
loc = player.worldOrientation.inverted() * woc
intensity = 0.2
motion_actuator.dLoc = loc * intensity
To make it clear, if my character is on a mountain, i want to be able to tune the motion actuator such the character would be able to slide at constant velocity to the top of the mountain no matter the character’s orientation or the mountain’s flank . In would act like an anti-gravity force that comes from the negation of the ground.hitNormal
per the docs (irc), those two lines are the same. getAxisVect is just multiply matrix inverse.
however, that isnt how to achieve what you want. i dont have the docs handy, but you should be able to create a Matrix or Quat rotation based on a vector or theres a owner.getAxisVect((0,0,1)).rotation_difference(nrm) and then multiply your local movement vector by player orientation and then by the matrix based on the normal. apply that vector to world position.
an additional point, since you are already using raycast, why not simply move the player an absolute distance from the hit point. or add the difference if using a movement vector.
as you can see it works as it. I did understood that getAxisVect() was computing some world vector difference and that i could derivate a local orientation with a wo.inverted() * . But you can see it’s more simple than that. In the demo, i just set .dLoc with -vec/5 to make it simple, but that value has to be added to the inital motion values.
the goal is to add that force to an existing .dLoc setup of moving human character in order to “cancel” the gravity effect that makes the character glide down even on a slight slope. It’s not really about moving a box to some location. The demo shows that if you over-do the “cancel” effect , it will naturally brings the player to the top. Also yes, in my game , all the player’s rot and loc are outputed in a motion actuator.