So I’m attempting to make a dash and a slide, my method for moving the player is the Launch Player and while I like the distance I have them set I’m wanting it to take a little bit longer for the player to actually reach that full distance. I’m not wanting it to be a shorter distance though. Any idea how I can go about this?
If your dash takes place on the ground, you might consider the friction on the surfaces, using a Phys Mat and playing around with the settings. This could be changed dynamically.
You could vary the vector direction and length (I’m not quite sure why you are using acceleration, but you may have good reason) you feed into Launch Character, and modify it’s strength simply by multiplying it with a float. Again, this could be changed dynamically.
Also, Jump, Add Force and Add Impulse are also options (with varying degrees of control). You might consider even dynamically applying opposing velocities to be sure the character stops where you intend.
It’s worth being aware that Launch Character will set your actor to falling when it fires. This might cause twitching if you do it horizontally on the ground when it switches from Falling to Walking.
It’s also worth being aware that each computer’s tick rate may affect the distance your pawn/character is thrust. The upcoming (and experimental in 5.4) Mover component is designed to avoid this type of issue… and will replace the Character actor type. Here’s a video from Unreal Fest just a few days ago. An Introduction to the Mover Plugin | Unreal Fest 2024 (youtube.com)
Thank you for the in depth response!
The reason I was using character acceleration is it allows me to essentially have the dash go based off of player input rather than just what direction they’re facing. This made the dash feel a lot more responsive and allowed for greater control which I’d like to keep if possible.
Interesting! i like Ur idea of keeping dynamic control of your ‘dash’ while it’s active. I’m still not entirely understanding why ‘Get Current Acceleration’ instead of 'Get Velocity’ or ‘Get Forward Vector’ but perhaps U have something specific in mind. There are a bunch of ways U could approach this.
Here is a simple, but different, approach. On the Character component, with a Timeline or Timer, in whichever Movement Mode U are using, U could temporarily increase the top speed (and/or acceleration of your Character). Again, while the timeline is playing, U could even multiply the speed input (like maybe from the ‘W’ key or forward input) temporarily to 1. U could also put a dash ‘cancel’ in there if the player releases the forward control somewhere to add a little more tactical depth.
U can control the lateral grip on the ground and in the air to tweak the feel of Ur dash, by adjusting the skid/slip as the character turns.
Hey thank you for another very in-depth response and also for recommending timelines. I honestly didn’t know they existed and they’ve actually solved the problem!
I was wondering if timelines are intensive performance wise cause I’m realizing that a lot of my current logic could be simplified quite a bit by using them. For context the dash and slide have a lot of different conditions that need to be met and taken into account to catch any edge cases. Currently I have quite a few different functions where the only thing they do is update the value of boolean so I can do it after a set time with a timer(trying to avoid delays cause my understanding is that they are overall a huge issue and would be better off replaced in logic with timers) or act as windows that are going “okay you’re dashing, okay you’ve stopped dashing”. A good amount of these could be done on the fly with a timeline without having to make a bunch of different functions to get called via timers and would overall be more accurate as to what’s actually happening behind the scenes.
If timelines are something that should be used sparingly is there another way I can change the value of a boolean after a set time without needing to make a whole new function for it while also avoiding the use of delays?
I’m worried that the constant calling of different functions to just change the value of a boolean will be bad for performance.
I was also wondering if there’s something I could use other than add impulse/launch character to get the effect of the dodge/dash. While I like the current feel that I have it at, I’d like to be able to make the dashes act the same every single time they’re used and overall just have more control over the feel of the dashes. Add impulse also just feels a bit inconsistent, but that could entirely be my current implementation.
Again thank you for all of your help and patience, I do not think I would have ever figured this out on my own.
Thank U @JakTac, timelines are great! While they are playing, they use about the same resources as Tick (I think). The benefit is that, while the aren’t playing, they don’t use any. So U can just call them to do repetitive things when certain conditions are met (open a door, move something from A to B, turn your player around, etc. etc.). Definitely check a few YouTube videos on these.
It sounds like the native timeline functions like ‘Stop’, ‘IsPlaying’, etc will really help.
It looks like U are going in the right direction with Ur dash. But, for reasons in my reply earlier, I also wouldn’t use ‘AddImpulse’, ‘AddForce’, ‘Launch’ etc:
- acceleration will look natural (not instant, unless U choose it)
- player always keeps control of the Character in terms of direction
- player can cancel it by releasing the dash button early
So, on your timeline (or a timer), change ‘AddImpulse’ to setting Ur Character’s movement mode (whichever ones you are using, like walking or flying) top speed with a ‘DoOnce’ node (and changing the acceleration if required in the same way). This will give U the dash. When the timeline ends, set the top speed and acceleration back to normal (the one-time ‘Update’ pin on the timeline output is useful for this). If it looks smooth with just one-time events, switch it to a Timer (cheaper). If it doesn’t look smooth, keep it in a Timeline and use a float track output to gradually ramp up the top speed (and acceleration if needed) and decrease it towards the end.
So after a bit of thinking this is what I’ve ended up with.
I need to play around with speeds and length of timer but overall it works well. I was wondering if I could get your inputs on this and if you knew a way I could prevent the player from losing height in the air while this dash is active?
Again thank you for all of your help!
U are welcome! It looks good
Regarding falling while dashing in the air, here are some options that may suit what U are aiming for:
- turn off or reduce ‘gravity’ on Ur character temporarily
- set Ur movement mode to ‘flying’ as U dash (it will switch to ‘walking’, when the capsule touches the ground)
- apply a counter force* to keep Ur character in the air temporarily with ‘AddForce’
Also, at the moment, U are only changing the ‘walk’ movement mode speed. So if U’d like a flying dash, this is something to consider.
*the snippet below shows how I stop my character from skidding in the air as it turns. It’s not ideal but it’s the only way I’ve found. It’s not a 100% match for Ur purpose, so U can just adjust it suit Ur needs.
So I’m attempting to make this air dash but part of the issue is that even if gravity scale is at 0 you still keep the momentum from the initial jump. The big problem that I’m running into is that the dash still doesn’t really move much while in air nor does it have like any speed. The dash also doesn’t run the same distance or speed if the player activates when they aren’t already moving. Is there some way I can have the dash cancel out like all current acceleration or something like that?
I’m trying to make this feel essentially identical to launch character when pressed. The way the dash works is there is no holding you just press the button and it immediately launches you in the direction you’re looking, or in the direction the players was walking if there’s player walking input.
Interesting, there is a boolean for if the player is falling (i.e. in the air).
Or, even neater, somewhere after the player presses the dash key, use a ‘Switch on Movement Mode’ to modify the logic for each mode.
Then I’d instantly switch the character movement mode to flying. Have the flying movement mode set up as suits U with regard to gravity, acceleration, top speed etc. (run on a timeline or timer in the same way U did the for the walking movement mode).
If U set the walking/flying modes’ acceleration very high, the boost will seem instant.
U could use “Launch Character” too, and to stop just apply a counter force when Ur dash time is up (see the ‘anti skid’ snippet above and apply the counter force in the negative direction.
I don’t have the editor in front of me right now, but I’m fairly sure there is a ‘Cancel Movement’. or ‘Cancel All Velocity’ node U could apply once to zero all velocity right before U begin the launch or dash acceleration.
It’s a neat puzzle Here’s a, really rough, partially complete, and untested… outline of one possible approach.
Also, I just remembered here’s one node that stops movement. I think there are others if U hunt around for them in BP, so U can find one that suits Ur purpose.
With regard to acceleration/deceleration curves, there is a great summary here in the middle of this talk: