# Character Velocity decreased when jumping

Yeah, I believe this is causing the issue where the line force is interfering with the jumping force.

Do you know how you are setting the direction of the line force? When you jump the line force might somehow to directed downwards and ruin the jump.

I’m setting the line force towards a part and the direction its going to, is relative to where the camera is looking at

I agree that the LineForce is most likely interfering with the VectorForce.

Ideally, you should be using a VectorForce for movement. However, VectorForces directly affect the acceleration of your character, so it will continually speed up. Instead, we want the character to reach a constant speed and keep that speed. The solution is to simulate a drag force. That way, your VectorForce will bring you to a certain velocity and then stop. So if you’re able to switch your movement to a VectorForce, the jumping will likely not interfere with it.

I can supply some code when I wake up tomorrow because I’ve done this before.

2 Likes

So I should switch my movement from LineForce to VectorForce? As for the continuous build up of the players’ velocity, I also encountered this when using LineForce so I just used math.clamp in order to cap the speed at 24 on the x and z axis. Also supplying the code would really be helpful

Ok what you’re doing is kind of a hack haha. I actually don’t know how LineForces work (and the devhub article was kinda confusing) but a VectorForce should work for your case. I’m boutta sleep so I’ll send it later.

3 Likes

Yeah, any more details on what this part is? the attachment setup between parts.

Are you exactly sure the line force is in the horizontal direction?

I mean line force can work exactly the same as vector force but it’s kinda harder to set the direction as you would need to fiddle with both attachment positions instead of adjusting just one vector force.

Edit: Also your character looks kinda like the Hello World bot lol I would love to see a game based on that.

1 Like

My LineForce setup basically has 2 attachments, one for the HumanoidRootPart and one for a seperate part which I use as the part that determines the direction of where the player is moving to. I basically position the part depending on where the camera is and use the HumanoidRootPart’s position as the base position for the part.

Also yeah the character is based of the Hello World bot, I made a version of this a while back but it was pretty unorganised and buggy lol

Sorry but I’m wondering about this exact detail. Are you constantly changing the position of this part to be horizontal with the HumanoidRootPart’s? any images of this part made visible to debug the direction of the line force?

I’m changing the part’s position based on the characters input and camera’s direction

Video of what it looks like (White neon part is the part used for the LineForce):

Perhaps print out/use the lua debugger to find the vector between attachments. If it’s horizontal then the y value should be zero.

Then try jumping alongside the print debugging it should horizontal along the floor as well.

Sorry I haven’t heard of the Lua Debugger before, can you tell me what it is and how to use it?

Ok I found my code! It uses one VectorForce and every frame it calculates thrust, drag, and lift and then does `VectorForce.Force = thrust + drag + lift`. That was for a honey bee, so yours is probably going to be `thrust + drag + jump`.

## Thrust

Thrust is a force in the direction you're walking. A force needs a mass and an acceleration. So, it'll look like

`Thrust = MASS * ACCELERATION * MoveDirection`

where `MASS` and `ACCELERATION` are constants. The mass will be the mass of your character. The acceleration adjusts how quickly we reach our desired speed.

## Drag

Without a drag force, our thrust will continue to pick up speed. From what I recall, I used a basic drag force equation from my physics class.

`Viscosity = MASS * ACCELERATION / MAX_VELOCITY`
`Drag = -Velocity * Viscosity`

We already know what `MASS` and `ACCELERATION` are. The constant `MAX_VELOCITY` is the desired speed of your character. Those three make up `Viscosity`. The last variable to know is `Velocity`, which is the actual velocity of your character (not the velocity we want, but where it actually is). We probably don’t want jumping to interfere with the drag force for moving, so `Velocity` should only be on the x-z plane.

`Velocity = Character.PrimaryPart.Velocity * Vector3.new(1, 0, 1)`

This eliminates the y-component of the character’s velocity.

## Jump

It seems that you already have jump figured out-- it's applying a force for a short amount of time. And then we're just gonna add that force at the very end like I said.

`VectorForce.Force = Thrust + Drag + Jump`

Hope this helps. Lmk if you have any questions.

EDIT: Fixed some formulas

3 Likes

I think it has something to do with the workspace’s gravity. (I’m not sure though)

I tried the method you showed above but the player doesn’t seem to be moving. It’s remains stationary if i give any input. It may be that I need to give it more power but I’m not sure.

You need to use non euler to create a temporary conic so that you can multiply the semi major axis, semi major being the horizontal and semi minor being the vertical velocity units not actual velocity. Then set that to the cube as a position

Euler has a million things named after him. What does that mean in this context?

Which conic?

@HavocOmega
Here, I had a quick go at it. See if you can pick out anything that I’ve done that might be useful to you.
Moving.rbxl (28.8 KB)

EDIT: Ehhh I feel like this isn’t very helpful. If the LineForce was working then stick with what you got. Maybe you can manipulate the one LineForce to do both moving and jumping instead of a separate VectorForce for jumping.

3 Likes

Non Euler integration, my bad. Conic being the cube it self http://nbodyphysics.com/blog/

I don’t see how euler/non-euler integration is related. OP isn’t dealing with orbits. All they need is to move at a constant velocity and apply an impulse vertically to jump.

I implemented the method that was shown in the place file and it works really well now! I greatly appreciate the help you gave me!

2 Likes