Search code examples
pythonphysicspymunk

How do you use apply_impulse correctly?


I'm just starting out with the PyMunk physics library. I'm having trouble using apply_impulse(). I'm calling it like this:

player.body.apply_impulse(player.body, (10,10), (10,10) )

However, I'm getting this error:

TypeError: apply_impulse() takes at most 3 arguments (4 given)

Why is this and what's the correct way to call apply_impulse()?


Solution

  • When you call a member function on its object you usually don't need to pass the object itself as the first parameter. self is in the function definition of every member function but not in the function call.

    see this post: What is the purpose of self?