Topic: Object Velocity

Hello,
I am sorry to be a bother but I have a small question. Is there a way to limit an objects velocity and not use the damping?

Last edited by Riddikk (2013-08-02 00:06:06)

Re: Object Velocity

Hi,

do you mean like the object should behave normally with no damping but could not go faster than a certain velocity ?
or do you mean the object will be affected by a sort of resistance or friction ?

Re: Object Velocity

Yes the object should behave normally with no damping or any kind of resistance but could not go faster than a certain velocity. Is this possible?

Re: Object Velocity

I think you can do something like that in lua, I'm not sure how precise it will be but it should work.

you can try to normalize the force if the speed reach some amount :

force = getCentralForce(object)
speed = length(force)

if speed > maxSpeed then
    force = normalize(force)*maxSpeed
    clearForces(object)
    addCentralForce(object, force)
    -- you might need to do the same with the torque if you want to limit rotation speed too
end

or by applying an inverse force if you want it to be more smooth :

force = getCentralForce(object)
speed = length(force)

if speed > maxSpeed then
    addCentralForce(object, force*(-0.01))
end

Re: Object Velocity

Thank you for the help I am sure this works .However I am too big of an idiot to implement it properly, so I did not manage to make it work .I am sorry to waste your time and I'm sure you have better things to do but can you please take a look on my script? http://db.tt/uiNNfUcQ

Re: Object Velocity

first this two line need to be inside onSceneUpdate :
force = getCentralForce(Player)
speed = length(force)

but you are not using "force" or "speed" variables.

What is the problem with your script ? is it not compiling or just acting strange ?

I don't know what your script does exactly, but I can say that you should do "thrust cap" after "raise thrust\lower" and not before.

If you just want to add this velocity limitation we talked about, try to add this after "--Movement RCS" block :

force = getCentralForce(Player)
speed = length(force)

if speed > maxSpeed then
    addCentralForce(Player, force*(-0.1))
end

Re: Object Velocity

Thank you so much for all the help you have given me. It's working very well now that I have made the adjustments you recommended, thank you again for taking the time and helping a beginner.