I want the vectorforce physics to be constant

I attempted your method, but the acceleration acted weird in both directions.

In what way did it act weird? Could you elaborate or provide an example place file? You can probably fix your issue by changing your Power or Drag.

I had to flip some stuff when I tested it out to get it to work properly as whether or not each value should be positive or negative depends on your seat and chassis orientation.


An alternative to having drag on just the forward/backward axis is to have it on all axes, which would look like this:

AxisVelocity = car.Chassis.CFrame:vectorToObjectSpace(car.Chassis.Velocity)
vf.Force = Vector3.new(Throttle*Power,0,0) - AxisVelocity*Drag

This might produce better results for you, too. This is 3D drag instead of 1D drag.

3D drag is somewhat like the first example you tried. 1D drag is like the last one you tried.

Edit: The first example you tried got the speed as 3D drag but applied it on only 1D.


I decided to put together an example place with both 3D drag and 1D drag “cars” for all 4 directions (+X, -X, +Z, -Z). Based on what I’ve seen so far, your cars look like they’re +X cars.
(+X, -X, +Z, -Z = East, West, South, North = Left, Right, Backward, Forward)

The “cars” I use to test this are just plates with low friction and vehicle seats because I didn’t want to rig up a whole car just to test a small piece of code. You can ignore the Steer stuff – I did that just so I could test how it reacts while turning.

DragCarsAxesExamples.rbxl (17.7 KB)

Corecii’s should have worked, as should my example before I added the Dir and after I updated the speed code. Using 3D drag should be pretty much irrelevant here, and might actually make some weird results if the force isn’t acting at the cars center of mass.

Edit: I’m wondering if there’s a problem with the force being applied in an attachment? If the X direction of the chassis isn’t forward/backward, then none of it works.

1 Like

Here is a place file your method works except that once I let go of A or D(my throttle is attached to whether or not you’re pushing down these keys) the speed remains stable and doesn’t go down.

Place file(I do the physics calculations on the client once they have been given NetworkOwnership):
ChasissXZ.rbxl (110.6 KB)

Any help is appreciated


Your throttle and drag are not lining up properly (throttle is going in the same direction as drag – it should be going in the opposite direction). This is what causes the car to speed up instead of slowing down.

  • This is because your attachment is flipped 180 degrees.
    • I expected the attachment and the car to be facing the same direction.
    • Because the attachment is facing the opposite direction, your Throttle force is facing the opposite direction of what it should.
    • Because your Throttle force is facing the opposite direction of what it should, it’s going the same direction as your Drag
    • This results in the car speeding up due to “Drag” instead of slowing down.
  • We can solve this by either…
    • un-flipping your attachment so it’s lined up with Plate then flipping the Throttle to negative. This is a -X car, not a +X car!
    • OR making the drag relative to the attachment instead of being relative to the Plate.

I’m going to make the drag relative to the attachment as this is easier to configure. Luckily, attachments have a WorldCFrame property, so this makes it really easy to change out existing code.

This

local AxisVelocity = CurrentVehicle.Chasis.Plate.CFrame:vectorToObjectSpace(CurrentVehicle.Chasis.Plate.Velocity)

becomes this

local AxisVelocity = CurrentVehicle.Chasis.Plate.vf.Attachment0.WorldCFrame:vectorToObjectSpace(CurrentVehicle.Chasis.Plate.Velocity)

Now the AxisVelocity is relative to the attachment rather than the Plate.


Here’s a place file. The only practical change is the one line above. I also did these things, but they don’t affect the operation of the car:

  • Removed the unused variables and commented-out code in the VectorForce handling section of NewVehicle
  • Renamed the attachment that the VectorForce uses to VectorForceAttachment so that it’s easier to find in Studio.

FixedChassisXZ.rbxl (110.5 KB)

7 Likes

Thank you for work, it’s greatly appreciated! I’ll tinker around with the variables to my liking.