So im trying to make a movement script and i want it to have a max speed and min speed iv'e tried using the object.applyForce((0, 10, 0)) but that just keeps adding up the speed of the object.


If you want it to have acceleration and inertia, make sure to use this method:

  • Add a property to your player called speed(or something that will be easy to understand for what it is used.
  • Set it to Integer, leave it's value 0.
  • Add property sensor and keyboard sensor to your object. Add that key in keyboard sensor, which will make your character move. Make it true level triggering and set frequency to your own wish- the bigger frequency, the slower character will accelerate. Connect to and controller.
  • Select interval in property sensor. Select your 'speed' property in it. Make it's interval from 0 up to 10 or bigger number. Enable true level triggering and set frequency identical to the one used in keyboard sensor.
  • Connect also property sensor to and controller.
  • Add property actuator. Select your 'speed' property it. Make it Add. In bottom input type 1 or +1.
  • Now repeat this again, but make sure tu use different interval(if previous was from 1 up to 10, thn now it is from 11 up to 20 etc.) You can play around with the add property and frequency.
  • Now do the same, but invert. Repeat the same proccess, but make sure you use invert in keyboard sensor and the last interval's biggest number is bigger than in positive keyboard use(if previously your biggest numbers were 21 - 30 and add property always was +1, than use 31 in last property, but anyway, if you add more in that property, make sure to make also that number much bigger than previous(positive keyboard press).
  • Add property sensors with intervals(as ymuch as you wish). Use different intervals in each. Connect them to and controllers and to motion actuators. Make each motion actuator move a bit faster than previous.

Now you should have working acceleration and inertia. Sorry for long text:D If you need, ask me for .blend example here!;)

EDIT Here is .blend: DOWNLOAD


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.