How to add current/flow?

ChristianWiele

Active member
Hi,

I would like to simulate a water current. So the character should move with the current when being idle in the water, and the swim speed will alter depending on going with/against the stream. What would be the best way to implement this feature?

Regards, Christian
 
At the lowest level you are wanting to modify the position of the character. To do that you can modify Swim.UpdatePosition to apply your own forces. You'll want to add these forces to the AbilityMotor.
 
That's what I tried, and what basically works. But I ran into a problem because my setup is a little bit more advanced. I implemented a bird fly ability. The bird is a combination of the swim and rideable ability, while the character has a modified ride ability. And now I try to add a wind force. Without the force, everything works fine. The character is moving in sync with the bird (as the ride ability does). But if I add an additional wind force to the bird, the character starts to be off sync.
I checked the position of the m_RideLocation from the bird, and the character. Without the additional force, both positions are identical within the same fixed update loop. But if I add the force, both positions are different, causing the shift of the character. The bird update runs before the character. So between the bird and character update, the bird is moved to a new position.
Bildschirmfoto 2021-02-04 um 15.19.33.png
 
This does sound more complicated. It's tough to say without debugging it but one way you could solve this is by telling the riding character the position rather than relying on the RideLocation.
 
I switched from fixed to update mode, and this fixed it. I could not figured out, why the position was updated outside the fixed update loop.
 
Top