Switch AI and player control = buoyancy bug

I have a game with a few Character BP pawns and the player can switch control between each one. The other characters follow the controlled character by switching their controls to AI and having them do a Move To Location Or Actor with the player’s controlled actor.

The characters have different buoyancies, some float (b=1.5) and some sink (b=.95). Under control, they float or sink fine and “IsSwimming” is correct. This is using a regular physics volume that has Water Volume set and a fluid friction of 0.35

However, when I first switch to a pawn that has followed another pawn into the water, “IsSwimming” is false even if they are in the water. This isn’t a terrible bug, but the next one is –

The sudden switch from AI controlled without IsSwimming to controlled and (at some stage) finding itself in water, produces a weird inverted-buoyancy teleport: if I switch to the pawn that is under water, it will teleport to above the water! It doesn’t even move there, it appears there. The pawns with b=1.5 exhibit the reverse – they suddenly move further underwater and bob back up. Once I’ve switched to them and IsSwimming is set correctly, switching between them works fine.

This only happens when they move into or out of the water under AI control, such that IsSwimming isn’t set correctly. I tried seeing if I could force a recalculation of IsSwimming by teleporting to the same or a nearby spot, but that didn’t seem to work. And I can’t seem to set the variable manually.

Hello,

Would you be able to provide a test project so we can look into your setup, as it seems like there would be a large margin for error in attempting to reproduce this in a clean project.

Please zip up the project, upload it to dropbox, and provide a link through PM on the forums. Here is the link to where you can send me a PM: https://forums.unrealengine.com/member.php?160394-Sean-Flint

Hmm, after experimenting with different buoyancies and changing pawn controlling, it doesn’t seem to be directly related to buoyancy but more with which pawn is controlled at the start.

It’s still pretty weird, but I’ll consider this an incorrect bug report until I figure out more of what’s really happening.

Ah, figured out the real problem – somehow, the mass of the pawn that sinks was really small (unrealistically small), which seems to really confuse the physics during a switch like this, even with an explicit buoyancy of 0.95, so it would immediately think it needed to bob up a ridiculous amount.

Ah, figured out the REAL real problem – one weird part of my movement code was being triggered when it shouldn’t have been.