Moving forward applies constant force

I have uploaded my blend file here so you can see what’s going on:

In short, when you press any of the keys (Up, Down, Left, Right arrows) it seems to apply constant force to the tank object. This is not what I expected to happen. One keystroke shouldn’t = constant force. I know that it’s not repeatedly activating the actuator that applies force in the relevant direction as well, because I added a debug print.

Steps to replicate problem:

  • Load up blend file
  • Press P
  • Press the up arrow on your keyboard once (don’t hold)

You’ll notice the object moves forward constantly, rather than applying the force of -5 in the Y axis just once to make it move forward slightly, then slow down.

Any suggestions would be welcome.

Alright, so I checked out your blend file.

I’m unable to replicate the problem. I press up arrow, and the tank moves forward until I let go of up arrow; at which point it slides to a stop.

Either your problem isn’t occurring for me, or I’m not understanding what the problem is.
Also, I was a little puzzled at the code for tank movement.

Your tank movement code tended to look more or less like this:

if key.isPositive() and tank.ready: # your code was a bit different, but for example's sake...
    GameLogic.addActiveActuator(act, 1)
if not key.isPositive() and tank.ready:
    GameLogic.addActiveActuator(act, 0)

I assumed you probably meant something more like:

if key.isPositive() and tank.ready:
    GameLogic.addActiveActuator(act, 1)
    GameLogic.addActiveActuator(act, 0)

Also, I couldn’t help but notice that you were about to start on some networking.
You imported the threading module, though I regret to inform you, that threading doesn’t work in the game engine.

Best of Luck on your online tank game.

Hi Chase,

Thanks for looking at the file. I forgot about this thread, and had uploaded a more fresh version of the file, which was the one you downloaded (which I’d since fixed the issue in).

And indeed, I’m trying to make a basic game server for my game. It’s been the bane of my life the last 2 days so I’ve taken a break :wink:

Thanks again for looking at it!