Player clips into floor with linetracing-based movement

Hey, so in my game, I have a “dash” mechanic. This mechanic relies on linetracing to determine where to dash to (also a “Get Forward Vector” node to see where I’m pointing the camera). However, whenever I “dash”, the player clips into the floor for a split second and then pops right back out. How can I smooth this out? Here is the entire program for my “dash” mechanic.

Hey there @Neoniclide! So generally you’d decide how you want to handle edge cases like this. In most cases, you’d just want the player to stop if they have to clip into something. This is what the Sweep portion of your set actor location node is for. It will sweep where the player is intended to end up and cancel that movement if the player will be clipping into something. Sounds great in the instance your ground is very flat, but as soon as you have to dash up a hill it gets to be a problem. You’ll always sweep and hit the floor.

This is usually why for real time games you wouldn’t use the trace to determine the dash, but since you are you may need to start the trace at the floor and iterate on the movement accordingly if it goes up.

This isn’t the preferred method, it’s usually better to define a direction for the roll/dash and have the player move in it quickly via it’s character component if you use that. It will allow you to remain on the ground and handle movement cleanly, however, this makes it more effort to handle air dashing.

That said, everyone does dashing differently and there’s a million ways to do it, so I’ve brought a good resource on a basic dash if you need a less conformed one.

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

Hey SupportiveEntity, the point of this mechanic is to dash to wherever the player is looking as long as there’s an object (so that they can dash up onto a high ledge if need be) so directional dashing didn’t seem the best way in my opinion. However, you said there is a possible yet extensive way to accomplish this using directional dashing? How could I do this?

It does definitely depend how rigid/accurate you want the system to be, if this is really just going to be a targeted “Zip to point without fail” button, then the way you handle it will work, but we’ll need to handle for collision cases either pre-emptively with making sure the path is clear, or correcting mid dash (harder but can feel slightly more reactive). If you’d prefer it be floaty and more room for error, ie dashing towards a point, but if you do it wrong you smack into a wall/floor. This is more just pointing a launch (or direct move for accuracy) where you want it to go, and then firing it with little regard for the outcome. This can be messier, but for certain games it’s also more player agency.

Another way is to disallow dashes that would put you in the ground by pre-sweep but that’s just the same as using traces to check.

There really are a million ways to do this, but all slightly different than the last. So let’s first define how you want it, and then I’ll see if it’ll be easier for me to make up a quick demo or find a resource if it’s got to be a bit more complex.

Does it need to be reliable? (IE if you hit the dash while there’s an indicator or lock on, you ALWAYS go to it, sliding on terrain if need be (harder).)

Is the dash soft or hard targeted? (Soft is that a little indicator comes up during normal play, hard is that you are forced to look at it to initiate the action)

2022-12-22 03-04-47.mkv (8.6 MB)

This is what my “dash” looks like as of right now (with a wall run), I love the way this feels, it feels super fast and takes me exactly where I want to go (but you can kind of see the clipping). If I understood your terminology correctly (I’m new so still learning), it is reliable and soft targeted (Also I’m sorry it uploaded as a file, I don’t know how to make it upload as a video).

I’ve uploaded it to youtube so you don’t have to download it