VectorForce not being applied in the proper direction

I’m using a combination of a VectorForce and a Torque to move and turn my boat. I’m also using an AngularVelocity and AlignPosition to keep the boat at sea level and make sure it does not tip over but I do not think it is related to this issue.

My Issue is that when the boat is going forward and turns, instead of the vectorforce being applied in the direction the boat is facing, it’s like the force is being applied in a different direction and it makes the movement look really bad.

Here is the code I’m using to calculate the force for the vectorforce:

vehicleSeat.F.Force = Vector3.new(vehicleSeat.Throttle * force, 0, 0)

And this is for the Torque:

PrimaryPart.T.Torque = Vector3.new(torque * -vehicleSeat.Steer,0,0)

Any help is appreciated, thanks

2 Likes

Try to give your Vector some sort of general direction so it knows where left and right is.

1 Like

General Direction? I tried the above calculation except this time I also multiplied the LookVector of the vehicleSeat but it resulted in it not even moving

Is the VectorForce relative to an attachment or to the world?

1 Like

Which direction is it going? If it’s being relative to the world (e.g. going the same direction no matter were the boat is turned), you should change vehicleSeat.F.RelativeTo = Enum.ActuatorRelativeTo.Attachment0 (either in studio or with code).

If it’s going in the wrong direction as in going sideways or something, try doing

vehicleSeat.F.Force = Vector3.new(0, 0, vehicleSeat.Throttle * force)

instead (potentially multiplying it by -1).

Nvm it is relative to Attachment0 not the world

What is the difference between relative to world and relative to attachment? I will try both

1 Like

Relative to attachment means it moves relative to the direction the seat is facing (e.g. right relative to seat is in the direction of the player’s right arm).

Relative to world means it moves relative to the world’s axis (so even if the boat turns, it will still go in the same direction).

You can think of the world’s axis like going North (always the same direction) instead of going forwards (which is relative to where you’re facing).

When I changed the VectorForce and the Torque RelativeTo, to the world, It stopped moving and does not move at all.

1 Like

Yeah you don’t want it relative to the world. That’s weird it stops moving though.

If you could send a video of what’s going wrong, that would be helpful.

Have you tried using this line instead?

vehicleSeat.F.Force = Vector3.new(0, 0, vehicleSeat.Throttle * force)

Here is a vid of it glitching out:

External Media
1 Like

Ohhhh. It’s because it’s using a Force instead of a Velocity. A force accelerates it in a direction, so it keeps going in that direction even after you turn (in real life, drag slows it down (especially on turns) but water physics aren’t really coded on Roblox, so its momentum keeps it going in the same direction).

You probably want to use a LinearVelocity.

1 Like

And I’m guessing for the LinearVelocity I’d just multiply the LookVector by how much force I want to apply?

Should the force I want to apply be a calculation of the mass of the boat multiplied by lets say 1.5?

1 Like

The linear velocity causes a speed in a certain direction, so the units are speed. What’s nice about that is you don’t need to do any math with the mass.

So if you want it to go 15 studs/second forward, just set it to be Vector(15,0,0).

Ok thanks, I will try it in the morning

1 Like

So do you think I should keep the Torque though? or should I change it to AngularVelocity or AlignOrientation?

You could use an angular velocity too.

The other way you could do this is use an angular velocity with its speed set to 0,0,0 and linear velocity with its speed also set to 0,0,0. This would act like a drag force: it would always try to slow down the boat and stop it from turning. Then use the force and torque you’re currently using.

That might be more realistic, since it would have the boat speed up and slow down.

But if I use this method wouldn’t it not solve the issue in the video above?

It worked somewhat nicely but the issue is still there, it is set relative to Attachment0 and the Torque is relative to Attachment0 aswell.

I also should mention I have an AlignOrientation and an AlignPosition which keeps the boat upright however I dont think those are related to this issue.

External Media

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