How do i make a force whilst having physics also being applied to it?

So I want to make a dodging system, but using a linearvelocity makes it so that physics like gravity do not apply whilst the dodge is active, what should i do so that it DOES apply gravity and such to the character whilst it dodges?

1 Like

Linear velocity has a line mode I believe. You can set the velocity in only one direction.

1 Like

How would i make it so that it goes in the direction of the character’s movement? I manage to get something working but it never goes in the direction of the character’s movement

The humanoid of the character has a property called “MoveDirection.” You can set the LinearVelocity’s RelativeTo to World and then set the LineDirection of the LinearVelocity to the MoveDirection of the humanoid.

I understand what you mean, but isn’t MoveDirection a Vector3? LineVelocity requires a number, and i don’t really know how to make that work…

Do you have sample code of your dodging system?

I’d imagine you’re doing something like

dodgeDirection = humanoid.MoveDirection
Part.AssemblyLinearVelocity = dodgeDirection * 50

Since most dodge systems are horizontal you don’t have to set the Y velocity. Just let gravity handle that part.

dodgeDirection = humanoid.MoveDirection
Part.AssemblyLinearVelocity = Vector3.new(dodgeDirection.X * 50, part.AssemblyLinearVelocity.Y, dodgeDirection.Z * 50)

Lastly if you want to keep the player’s momentum you can add to the players velocity instead of directly setting it.

dodgeDirection = humanoid.MoveDirection
Part.AssemblyLinearVelocity += dodgeDirection * 50
1 Like

Should Part be the HumanoidRootPart in this situation? Also, how would I make it so that this would stop? Because I want to make it so that successfully dodging an attack would stop the movement caused by dodging.

Reread my answer. LineVelocity can be set to whatever you would like, while LineDirection is set to the MoveDirection. To stop it, just make the Enabled property false.

1 Like

Yes, use the HumanoidRootPart and run it on a local script.

The dodging system I gave above is a one time run system, similar to a player jumping, you’ll quickly lose speed after the initial burst.

It depends on what type of dodging system you want to code. Do you have an idea of what you want to make?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.