Hello, I’m trying to set up a scenario and was amazed when I discovered that it wasn’t as simple as it perhaps should be.
I have a character, and I have a small river that the character walks through. When walking through that river, I am trying to have the water provide a constant force to the player, such that when walking against the flow, the character’s speed is reduced, when walking with the flow, their speed is increased, and they are pushed along when standing still.
It turns out this is apparently extremely awkward to do. You see, in my case, there are tight constraints on how the character can move, meaning that simply setting the player’s position each frame is not an option. I instead need to pass a movement vector to the player and let the character code resolve the situation.
However, I’ve tried various methods of doing this, and all but one produce the same, unsatisfactory result:
First I tried AddForce on the movement component.
Then I tried setting the velocity variable directly.
Next I tried adding a Momentum variable and applying it to the player during an override of MoveUpdatedComponentImpl.
These methods all produced the same behaviour: When walking against the flow and standing still, the player is pushed backwards (at the same speed). When walking with the flow, the player moves at the regular maximum speed, as though no force is being applied.
There was one method that produced the movement I was looking for, and that was using LaunchCharacter. However, for some bizarre reason that forces the player into the falling state, and is hard-coded into the system. So, while the movement is correct, none of the player’s animations are.
Frankly, this functionality should exist, and be as simple as plugging a vector into a function call. The fact that it isn’t that simple is somewhat ridiculous, as this is not exactly an uncommon request, and the fact that LaunchCharacter already does it (but forces the player to the falling state - which is, I believe, unnecessary, as if the player were launched upwards they would lose contact with the ground and the state would be set anyway) shows that it’s not even difficult to implement.
I’m likely to have to copy and paste the code that calls Launch now, which is a huge pain when this functionality should be standard.
EDIT: Having overridden the HandlePendingLaunch function (to do exactly the same thing, except without setting the movement mode), it now produces the same result as all the others, with the addition that I now can’t jump either.