You might want to check this out:
It’s UDK and UnityScript, but the logic should be relatively easy to port to UE4 C++ or Blueprint. At very least, reading the code should give you an idea of one way to achieve what you want. No matter what you do, you’re likely to have to do a lot of trial and error to get good results. There are lots of edge cases here that will need to be dealt with to make it fun to play.