How To Stop An Object From Moving

I am a somewhat experienced Blender user and I’m just getting back into Blender again :slight_smile:

I have been having problems with the movement of the character in a game I just started on yesterday. I settled on using servo for it, but I have a problem where if you walk into a wall and then stop, the character bounces back. I have tinkered around with anything I could think of to fix this problem, but nothing works.

So, my plan is to, in Python, completely stop the object from moving upon the release of the key. That way the character won’t bounce off the wall. I don’t want to disable the object’s dynamics though. That’s just about the only way I could think of fixing it. If anyone else has other ideas, please tell me.

Try messing with the wall’s restitut value. This is in the material buttons.

Add a material to the wall, select the “DYN” option near the color sliders, and lower the restitut value. Restitut is essentially the “bounciness” of the faces. Set this for 0 for the wall and your character should stop bouncing. You could also do this to your character.

For stopping an object completely (without python) you can use Servo. Just select 0 for the x, y, and z, and add both a min and a max force for all 3 axis.


No I already tried that and it didn’t work. And the restitute just makes it worse. I just need to know how to stop an object completely in python. I’m pretty sure I can get it to work then

To stop an object completely in Python:

ob = GameLogic.getCurrentController().owner

ob.setLinearVelocity(0, 0, 0, 1)

I didn’t test it, but I think it should work.

Tried it and I got this

“TypeError: setLinearVelocity() takes at most 2 arguments (4 given)”

I had this same question on irc some days ago and Moguri answered me with the same typo :stuck_out_tongue:

It’s: ob.setLinearVelocity([0, 0, 0], 1)

And that works perfectly :slight_smile: I personally always rather use setLinearVelocity instead of servo, it gives you much better control.

Thanks vibrunazo :smiley:

EDIT: I’m just gonna get rid of the servo and use that. Works much better!

Oops, sorry about that! I was mixing it up with the motion actuator’s setLinearVelocity() method, which takes 4 args. Yes, use a list or tuple for KX_GameObject.setLinearVelocity():

ob.setLinearVelocity([0, 0, 0], 1)

# or

ob.setLinearVelocity((0, 0, 0), 1)