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.
1 Answer
$\begingroup$
$\endgroup$
5
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 andkeyboard
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 toand
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 inkeyboard
sensor. - Connect also
property
sensor to and controller. - Add
property
actuator. Select your 'speed' property it. Make itAdd
. In bottom input type1
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 were21
-30
and add property always was +1, than use31
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 toand
controllers and tomotion
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
-
$\begingroup$ Yeah i'd like to see the .blend cause i got kinda lost xD $\endgroup$ Commented Jan 3, 2015 at 3:50
-
$\begingroup$ OK! I will edit a bit later! $\endgroup$ Commented Jan 3, 2015 at 6:23
-
-
-
$\begingroup$ Works for me- just click on it or go here: dropbox.com/s/bybkedsj7a8cwzy/AccInertiaExample.blend?dl=0 $\endgroup$ Commented Jan 3, 2015 at 16:35