Trying to implement a dash ability

debuggingmyhead

New member
Hello,

I'm using UFPS2 and I'm trying to implement a dash ability and have some questions. I apologize in advance if these might be general Unity questions, in which case I can seek answers elsewhere too.

Right now I have a "dash" ability script that I created and it works decent enough, but not quite what I'm trying to achieve. What I'm doing is when the ability starts, I'm applying a force via AddForce on the locomotion script based on the player's current velocity (so that they can dash in the direction they're pressing). This does work and pushes the character quickly in a direction, but it kinda jumps to the new spot, and it doesn't seem "natural".

Which brings me to my questions:
  1. Am I even going about this the right way (i.e. applying force at ability start via locomotion script)?
  2. If I add the force and choose more than 1 frame, does it get spread out evenly over all frames? And would that be the proper way to handle the physics of a dash?
  3. How might I go about preventing user input from effecting the movement physics during the duration of the dash?
  4. I'm also attempting to have two dash behaviors: quick tap is a normal length dash, and a long press in a longer dash. Each type would have a specific time duration (not based on the length of the button press) - Could you shed some light on how I might implement that via Abilities? Perhaps they should be separate abilities?

Any help is greatly appreciated!
 
1. Yes, applying a force is the correct method.
2. Yes, it does so I'd recommend applying it over multiple frames.
3. On the ability's general options you can specify if it should allow positional/rotational input.
4. You could have two abilities, or take a look at the jump example which subscribes to an input callback so it knows how much hold force to apply.
 
So, thanks again for pointing me in the right direction, I'm getting much better results now. Looking at the jump ability was very enlightening.

I do have just a few followup questions that hopefully are simple to answer:
  1. How might I go about stopping the ability when I hit a piece of room geometry? I'm trying to have the dash stop if the player hits a wall for example. Right now if I hit a wall I have no control over the movement until the duration of the dash ability expires (which makes sense).
  2. When I dash into an enemy it sends them flying I assume due to the physics interaction. Is there a simple way to dampen and/or completely prevent that behavior?
 
@debuggingmyhead Hi, is there perhaps a way you can share your Dash ability script perhaps? Im trying to create a Blink Teleport ability and I can see add force is the only way Im gonna be able to accomplish it.

Please any help on the matter would be immensely appreciated.
 
@SkobbejakGames , first is blink an instant, but presumed glide to the new position, or a teleport. I dont necessarily think either need to use forces. The fact you say "I can see add force is the only way Im gonna be able to accomplish it " makes me think you are after the appearance of transition rather than teleport? either way, capsule cast/capsule checks could be used prior to setting the players position?

@debuggingmyhead , just speculating: cast ahead of the dash and abort the ability when you get a hit? or monitor your velocity and abort when you it drops suddenly?
 
@DankP3 Thanks for the fast reply, I actually just want an instant teleport and then I just remembered the Teleporter script before I saw your reply, so Im gonna couple that with a ray cast to check distance and thickness of obstacles. Thanks for the help :)
 
@DankP3 Yeah now that you mention it a Capsule Check would be necessary. I just wanted to check, how would I go about making the Camera adjust smoothly as the player teleports as its a bit janky as it instantly moves to the player's new position?
 
Ah, thanks for the info. Yeah, hopefully we get a little bit more leeway (perhaps movement over a customizable number of frames) with the camera snapping next update.
 
Still looking for way to get the Dash Ability to work mid-air. No matter what I try the Dash Ability always just cancels out if I am doing it off a ledge or in mid-air. Once my character's feet detect that the character is mid-air the Dash Ability cancels.

Please, any help would be immensely appreciated cause this bug makes my Dash Ability useless and breaks my game.

The fact that there are multiple Dash Ability threads all still unresolved and with other people sitting with the same problem, proves this isn't a minor issue and a workable solution wouldn't just help me out but multiple other people also sitting with the same issue.

Apologies for the multiple replies, but I've sit with this issue for almost an entire year already and just can't get a working solution and it is preventing me from getting my game to function and play correctly.
 
Please do not create multiple posts with the same content - I am removing all but this one.

The dash ability isn't designed to work mid-air. I can add this to my feature request list though.
 
@Justin Apologies for the multiple posts, it's just an issue that's plagued the Dash Ability from the start and no matter what I do I can't get a work around for it and it is holding back my project.

Sorry I do realize that you are super busy, but if there is any way that I can somehow get a method to make this work I would be eternally grateful, cause I don't know what to do anymore.
 
Top