# How to Charge/Dash forward along surface?

Hello everyone, I have been struggling with this for a while now and I thought it might be time to make a post about it.

I’m trying to create a “charge” like ability, and my current setup is where the character makes a LineTrace forward, and sets the ActorLocation to the hit point over a short Timeline. it works perfectly on flat ground, but as soon as I hit just a little rock or like a 10 degree angled hill, the character stops there. Also when I use the ability from the top of a hill, he just slides forward, ignoring gravity alltogether, until the timeline is complete. I know why the problem occurs, and how this setup works, but I’m hoping for another solution to this, so I may slide along the surface of the ground. I haven’t come up with any good ideas, so I’m hoping for some help here. I also thought about launching the character in the forward vector with a pretty high Velocity, but I want it to charge / slide to the specified location no matter my characters velocity.

My project is a Third person game in version 4.25

Tried to upload a screenshot here, but I don’t know why it won’t start uploading. But i think you guys got the idea of what I’m trying to do, and how I approached this.

How to Charge/Dash forward along
surface?

This seems to work well enough:

my current setup is where the
character makes a LineTrace forward,
and sets the ActorLocation to the hit
point over a short Timeline

`Set Actor Location` can easily force an actor into geometry if you’re not properly accounting for collision. Your character has a `Movement Component` and `Capsule Collision` - take advantage of those by using Add Movement Input. This way you’ll achieve a reliable and efficient sliding collision.

Hey and thanks for the reply! This is defenitely something I’ll try when I get back to my computer!

The float value in the timeline is just the distance you want to travel, right? Also, does this work even without any velocity when the input is pressed? If so, it might just be exactly what I’m looking for, when I perfect it with ground friction etc.

I also don’t want my character to be able to move or rotate while charging, but I think I know how to deal with that.

Thank you very much! It worked perfectly with some minor number tweaking to match my vision of this ability! Wierdly enough I didn’t think of this as a solution since I’m not very familiar with the “Add Movement Input” node except from regular movement in corresponding axis.

Technically you do not need a timeline for this, if all I wanted was to give the player extra speed for X time, I’d use a Timer.

Only using a Timeline here because you mentioned it; admittedly, a TL would also give you more flexibility if you needed to interpolate some data. Play sounds at specific times, execute other effects, script, animations, update widgets and so on. Timeline is an OK choice here if you need the extra features.

Wierdly enough I didn’t think of this
as a solution since I’m not very
familiar with the “Add Movement Input”
node except from regular movement in
corresponding axis.

This method is nothing more than giving the player a lot of speed & acceleration over X time. It’s exactly the same method you’re familiar with. Makes things easier and gives you good control over collision.

The float value in the timeline is
just the distance you want to travel,
right?

The float in my original example is a 0-1 value over 1s; it helps to smoothen the velocity increase / decrease. You can get away without it ofc, and rely on acceleration parameter only.

Since we have acceleration and time here, we could calculate distance. Flip the equation around and adjust the TL’s rate - then it would fire for long enough to move over some distance.

And for input, you could try this:

Also, if you wanted a giant leap / jetpack boost, it could look like this:

There’s, obviously, polish to be done

Hope the examples help! Good luck with the rest.

Thank you so much for contributing, and for specifying your answer this much!
It really helped, and I now have the function I want. My main problem was that my character was going in a straight line no matter what, and the sweep ruined the ability to move in other angles, so this easily fixed that.

I removed the LineTrace completely

Also, the movement looks much more natural now that I add movement input with acceleration instead of just setting the ActorLocation over a set time.