I asked a question like this a while ago, but now I need help again.
I made a vehicle-like SENT that uses a series of values to determine how it moves based on player interaction: Speed, Acceleration, Handling, and Glide. They are all based on a 1-5 star scale rating (in numbers). I’ll probably change it to 10 eventually.
Speed and Acceleration should be pretty self explanatory.
Handling is the amount of control this entity has over its movement. Think of it as a car trying to stop or do a sharp turn. Low Handling means it will slide a lot more. Handling is converted to “control” in the SENT.
Here is an example of the equivalent of a 5-star Handling rating:
[lua]phys:ApplyForceCenter( ( vel * -1 ) + vec )[/lua]
Where vel is the current velocity of the entity, and vec is the new vector.
Now we need to throw handling into the mix.
Here’s what I had:
local control = ( 1 - ( 1 / handling ) ) * -1
phys:ApplyForceCenter( ( vel * control ) + vec )
Control will be a negative fraction. The problem I’m seeing is that if I multiply by a value greater than -1 (an entity with a handling rating less than 5), the entity will continue to accelerate, right?
Right now this is being called in **[ENT.PhysicsUpdate
http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=PhysObj.ComputeShadowControl)**), I could never get it to work. The wiki example is pretty awful for both and does not explain the enumerations well.
I’m wondering if I should use this: http://luabin.foszor.com/code/gamemodes/base/entities/entities/base_vehicle/shared.lua
Either way I need some help.
I may have more questions about this as it moves along.