I have a function that runs on tick, that shoots a line trace straight down and then through the impact normal it rotates the actor towards the ground. Here is the issue:
When I have “Orient Rotation to Movement” in the Character Movement Component set to true, this seems to clash, and the Character starts to jitter.
When Orient Rotation to Movement is set to false, it works fine, but my Character no longer steers the way I want it to. Also, if I set the Interp Speed to 0, it works fine as well, but that defeats the purpose of having it in the first place. I have tried switching from “Set Actor Rotation” to “Set World Rotation” using the Capsule Component or the Mesh component, but that didn’t help. I also tried using “Use Controller Desired Rotation” but that didn’t help either.
I use Unreal Engine 5.3
Thanks in advance
edit: If I set the delta seconds to 0 then it still isn’t rotated right, but it no longer jitters.
edit 2: I tried it in a different project and I had the same issue. The code looks fine to me, and I don’t know if it’s possibly a UE5.3 issue. In any case, I need this fixed asap
Can I ask what kind of project this is for, that you would be rotating the character to constantly be perpendicular to the ground? Is it for something akin to Super Mario Galaxy with smaller gravitational pockets? Because you typically shouldn’t have to do this, and usually you can set false gravity to another plane once upon retargeting gravity, “planets” are a little trickier.
Is there any way you could show video of what’s happening?
I’m thinking maybe the rotator could be conflicting with the “Orient Rotation to Movement” based on some additional math that may need to be done- You may need to do a DOT product for each axis if it’s 3D with things like halfpipes as well as slopes.
Disclaimer: This video is not associated with Unreal Engine, Epic Games, or their Partners.
I think orientrotationtomovement zeroes out yaw and pitch. Hence they jittering as your set actor rotation tries to overwrite it. Unless you’re feeling frisky and want to edit CharacterMovementComponent.cpp and recompile the engine source, your best bet would probably be to store the desired rotation as a var. Then fetch it in the anim bp and rotate the pelvis or root bone in the anim graph somewhere.
I tried something like that before, but that would also overwrite all animations that rotate the root bone. Also, for multiple reasons, I have the spring Arm for the camera parented to the Capsule Component, which means rotating the entire Actor also moves the camera in the way I want it to. I could get a similar effect by parenting the spring arm to the Head or Chest Bone or something, but that would cause issues with the animation again and so on.
Alright, I was able to find a band-aid fix for this issue. Meaning, I solved the issue to get everything working the way I wanted it to without resolving the actual cause of the issue.
The Problem was: “Orient Rotation towards Movement” clashes with “RInterp To” + “Set Actor Rotation” and causes the character to jitter slightly. I believe this wasn’t and issue until I updated the Engine Version to UE5.3
My band-aid fix: For my “Move Right” input axis, instead of using “Add Movement Input” I now use “Add World Rotation” with the Capsule Component as its target and using the Input Axis multiplied with the Rotation rate as the Yaw.
This does not fix the actual issue of “Orient Rotation towards Movement” clashing with “Set Actor Rotation”, but for now this works for me. I hope this helps people with similar issues, but again, the initial issue is still unresolved.
Yea, I could see how turning bones could be an issue when doing tricks and such. But depending on how the anim bp is set up, only tweaking the rotation in the snowboardy equivalent of “jogging” or “idle” states of a standard locomotion state machine might not be too bad. Alternatively, could also make a post-proccess control rig to adjust the feet and board using IK. This would likely be more time consuming than editing the source code, but it would also make the character more reactive to small bumps.