I am trying to create a dash attack like the one shown in this video, So far I have tried creating a body velocity pointing in the direction of the mouse which works fine but is very inconsistent as you can be flung when going into floors or walls. The second approach I have done is using a ray and trying to tween the character to the position of the result or max range if there is no result however it is very flickery because I assume my character is still being influenced by gravity and I don’t know what I should do to avoid this.
Edit: I think the solution to my problem is anchoring the rootpart and just running the tween on the client to reduce the jittering but I am now facing an issue where the humanoidrootpart seems to disconnect from the rest of the body after tweening and I dont know how to fix it. I am using tween service and tweening the position property of the humanoidrootpart.
With your BodyVelocity method, try leaving the Y axis of the BodyVelocity’s MaxForce at a value of 0, with the X and Z axis being high numbers. This should prevent flinging.
I want it to be able to go up and down though and this still wont prevent the flinging with walls, Im mostly looking for a way to smooth the tweening method because the only issue is just that it is very jittery.
If you’re going to use TweenService to animate the dash, you should be tweening the CFrame property instead of Position of HumanoidRootPart. Reason being that when you CFrame an anchored part, any other unanchored parts connected to it (welds, motors, weldconstraints etc.) will also move along with it, while the Position property only updates the part itself.
I feel like using a Tween here is unnecessary and only complicates the process further.
I would use a BodyPosition here. In your case (from what I understood, you wanna make it move to the cursor) you’d probably want to do something like this:
local targetPosition = Vector3.new(mouseHit.X, humanoidRootPart.Position.Y, mouseHit.Z)
-- multiply by the maximum distance you can dash for
local direction = (targetPosition - humanoidRootPart.Position).Unit * 30
local raycastResult = workspace:Raycast(humanoidRootPart.Position, direction)
-- do note that you're going to have to create a RaycastParams object ^^^
-- for it to not hit the character or anything else like that ^^^
bodyMover.Position = if raycastResult then raycastResult.Position
else humanoidRootPart.Position + direction
You can use raycast for better detection. To be exact the new BlockCast. For dash you can simply use BasePart:ApplyImpulse(VelocityDirection). And to counter that drag on ground view this video.
The problem with using a bodyposition from what I can tell is that the travel speed and time will become inconsistent because bodypositions strength is relative to the distance from the character and bodyposition.