Let’s imagine I want to create a Teleport() method with an option to drop precisely the character to the floor.
I know that the destination is roughly near the ground (maybe slightly above or below).
When using the FindFloor method which seems to be the best way…
CharacterMovementComponent->FindFloor(CapsuleBottomLocation, OutFloorResult, false);
For the sweep method to perform well in FindFloor should I…
- Move the character first to the destination so that the character Capsule is at the start location before calling FindFloor() to perform the Sweep test ? Or the function will work even if the character is still at the location before the teleport.
- Should I explicitly move the destination an offset above the ground so that the Sweep test downward will not start already in the floor ? (or is that performed automatically by FindFloor).
- For the first argument I guess I have to substract GetScaledCapsuleHalfHeight() to compute the Capsule bottom location if I have the character destination Location. Is that correct ?
- I see that FindFloor() code is dependent on states like bJustTeleported, so is it safe to use it without calling AActor::TeleportTo() first ?
Am I missing any simpler way in UE4 to do all that ? I saw that AActor::TeleportTo() calls some UpdateFloorFromAdjustment() but from the code it doesn’t seem to do an immediate drop to floor and I want to make sure Character doesn’t have to go through some Falling state. What is the clean way to do all that in UE4 ?