Jump to content

Vehicle handing for deceleration


Recommended Posts

Alright so I'm tired of how fast the vehicles are dropping in speed as soon you release the gas pedal, is there any handling option I can set that directly affects how fast or slow the deceleration will be. Or can it be done in other ways like comparing the speed in onClientRender with the previous stored speed and then set the speed a little higher than it's supposed to be if no buttons are pressed? any ideas?

Link to comment
7 hours ago, NeXuS™ said:

I dont know if you can do it with handlings, but maybe a trick would do with setElementVelocity.

I think that could work but it could also eventually be laggy and affect the sync with other players, which is a problem.

1 hour ago, Bananovy said:

Actually the higher vehicle's mass is the slower will decelerate. You can try to set high value for mass in handling when player isn't accelerating.

Mass does affect vehicle deceleration indeed, but it would also affect the weight obviously with many other negative side effects. The goal here is to make the handling feel more realistic and mass doesn't seem to accomplish that. Any other ideas?

Link to comment

maybe get the vehicle speed onClientRender when no keys are pressed (since you are complaining about the automatic deceleration that is caused by friction and gravity when the gas pedal is released) and then setting the vehicle speed to a lower speed, this way you can decide how long and how will your vehicle stop eventually according to the equations that you will use. For instance;

-- getElementSpeed : useful function
-- setElementSpeed : useful function

function automaticSpeedDeceleration()
   if getKeyState("fowards") == false then -- or even getControlState("accelerate") == false might be more useful here I think
    local speed = getElementSpeed(vehicle)
    setElementSpeed(vehicle,1,speed - (speed/4)^2)
    end
end
addEventHandler("onClientRender",root,automaticSpeedDeceleration)

Not quite sure how accurate can that be, but I guess something like that.

And if that works, You would probably need to lower the deceleration rate since it is happening on every frame, and making it big can cause the car to stop immediatley when no keys are pressed (I am talking about (speed/4)^2) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...