stop bobbing

ok well I found some scripts for a hover craft but I can get some of them to work and the one that dus work just wont stop bobbing soo cud some one take A look and help me


hover craft.blend (153 KB)

That’s because your system is based on an ideal spring: it looses no energy to heat or air resistence (it has no damping). Thus, it will go on forever (or until your computer overheats and dies, you go insane from watching and stop it, etc, etc).

I completely understand why you would want to use forces, so I combined F=ma and dx = 1/2at^2+v0t and solved for F, where t now becomes your new “spring constant”.
here’s the new code (with a bit of your original for context).

if posZ > 1.5: 
if posZ < 1.5: 
    timecst = .4 
    force = (2*((1.5-posZ)-own.getVelocity()[2]*timecst))/(timecst*timecst) 

Tada! I hope this is satisfactory.

Haha, you got it before me J09, but I agree with you.

The bobbing problem is done because of the lack of air friction.

force = stability+forceConstant*(1-posZ)

This can go on forever, since the +Z strenght will make the ship to go all the way up to the initial point, then it will fall till a certain point, to go up to the initil point again…

Thats the teorical part, now for a solution, you can take J09’s :slight_smile:

yah but how do I get that to work do I just have a allways sensor and a python controller

There’s a part of your code which says:

#If the object is above the resting value, there shouldn't
#be any force pulling it down.  On an actual spring, it
#would, but for a hovercraft we just want upwards force.
if posZ > 1:

print motion.getForce()[2]

gl.addActiveActuator(motion, 1)

#Other notes: in an actual example, you'd have to find

Replace the code called by else with:

timecst = .4
force = (2*((1.5-posZ)-own.getVelocity()[2]*timecst))/(timecst*timecst)