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
keyboardsensor 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
- Select interval in
propertysensor. 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
- Connect also
propertysensor to and controller.
propertyactuator. Select your 'speed' property it. Make it
Add. In bottom input type
- 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
keyboardsensor and the last interval's biggest number is bigger than in positive keyboard use(if previously your biggest numbers were
30and add property always was +1, than use
31in 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).
propertysensors with intervals(as ymuch as you wish). Use different intervals in each. Connect them to
andcontrollers and to
motionactuators. 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