I'm trying to make a cartwheel/ dodge to the side in ue4 but when the animation plays it moves out of the capsule and slides back. Is there a way to make the capsule move with the character in the animation.
It sounds like your animation is moving off of the root position. There are two options here out of the box. You could try using Root Motion https://docs.unrealengine.com/en-US/Engine/Animation/RootMotion/index.html, which would allow you to use the animation as is, while moving the capsule. However, Root Motion is limited, and I wouldn't advise heavy use of it. If you plan on using the navmesh for path finding, for example, Root Motion does not support path finding out of the box. It is also limited in multiplayer.
The proper way to do it is to kill all of the root motion on your animation and re-import it, or use the "Force Root Lock" checkbox in the animation asset editor. This will lock the animation at the root, and thus will always stay at the local space location of the skeletal mesh component. Then, you will need to procedurally move the character while playing the animation.
If you want to look at a BASIC example of how to set up animations, as well as a basic animation state machine the Unreal way, download the Epic Games Launcher and download https://www.unrealengine.com/marketplace/en-US/slug/paragon-shinbi. There is also a tutorial https://www.youtube.com/watch?v=yP4ygKHwlS0 which shows you some basics. In the description of this tutorial, there are other parts you can watch which cover different things. This is by no means the best way to do it, but this will get you started in the right direction, so you can understand the basics of the pipeline, and get your character working.