Slowdown Dash depending on distance of enemy (Raycasting)

I am currently working on a battleground game. We are trying to decelerate a frontal dash towards an enemy using ray casting (the closer the user when dashing the faster the deceleration).

I am not able to do it! I tried raycasting the distance infront of me and depending on the distance it reduces/increases the digit for decelerationStartFraction

solve method : Once you have that, you go through the list of characters and check if during that time, the player will be at a position where they are within a reasonable amount of range to the player, so then you get that position and that's the new ending position, you get the magnitude between that point and your starting position and the magnitude between your original ending position and your starting position, then you do original magnitude / new magnitude and you multiply the time values by the returned number

2 Likes

Are you not able to come up with how to do it? Here’s what I’d do:

  • Raycast a couple studs
  • If it intersects, get the intersection posiiton
  • Subtract the player’s position by the enemy’s position
  • Do the logic from there