Questions tagged [pymunk]

Pymunk is a 2D physics library for Python built on top of Chipmunk.

Pymunk is a 2D rigid body physics library for Python based on the MIT licensed Chipmunk Project. It's home page is http://www.pymunk.org/en/latest/.

According to the home page, Pymunk is intended to be easy to use and "pythonic". Pymunk allows you to define and simulate the behaviour of objects with mass, position, velocity and collision properties (i.e. a shape) in a 2D space. It is frequently used for game development. Pymunk provides a large number of examples.

Further Information

176 questions
3
votes
1 answer

Pymunk servo joint

How do you implement a "servo" joint in Pymunk? I'm trying to create a simple model where a box is balanced on a single thin "leg" below it. I've been able create a box and join it to the ground using a PinJoint, but there doesn't seem to be any way…
Cerin
  • 60,957
  • 96
  • 316
  • 522
3
votes
2 answers

Show PyMunk with PyGame - Python

I am trying to learn PyMunk and I used their basic example from the website: import pymunk space = pymunk.Space() space.gravity = 0,-1000 body = pymunk.Body(1,1666) body.position = 50,100 poly = pymunk.Poly.create_box(body) space.add(body,…
Teodor Cristian
  • 349
  • 4
  • 16
3
votes
1 answer

Transfer of energy from one object to another in collision (in pymunk/chipmunk)

This question is about pymunk, but I'm aware that there are a lot more Chimpunk users out there; so if your answer involves C/Chipmunk code, it's okay. While I don't know how to write C code, I can usually figure out what's going on if I read…
3
votes
2 answers

What types of velocity-over-time curve models an object sliding to a halt on a level surface?

I'm writing a little game with a top-down view of some sliding objects, like curling or shuffleboard. (I happen to be using PyMunk for the physics, but since this question is about physics simulations in general, don't worry about language…
3
votes
1 answer

How to make "compound" shapes in pymunk?

As the title says, How can I join/constraint 2 pymunk bodies/shapes so that they don't they act as one single object?? For example, in this case, I have a cricket bat, made up of 2 separate bodies and polys. I want to join the bat's "handle" to my…
pradyunsg
  • 18,287
  • 11
  • 43
  • 96
3
votes
1 answer

Pymunk body's shapes don't rotate when I rotate the body

In Pymunk, when I rotate a body, its shapes are not rotating. When I apply an impulse, the shapes move in sync, as expected. My google searches indicate that the body's shapes should be rotating when the body rotates. Am I fundamentally…
2
votes
1 answer

Why does my ball not stop rolling in Pymunk?

I am working with Pygame and Pymunk and my ball which is done with pymunk won’t stop rolling I think it has something to do with the friction but i do not know. Please help me. Thanks already. Is there a way to maybe set a rotation speed(but i think…
Hadeaiki
  • 21
  • 2
2
votes
1 answer

How To Use Pymunk Categories and Masks

I am making a python project with the 2D physics engine pymunk, but I am not familiar with pymunk or the base C library that it interatcs with, Chipmunk2D. I have quite a few different objects that I want to collide with others, but not collide with…
2
votes
2 answers

The particle is not moving so what is the problem?

I follow a youtube video 'https://www.youtube.com/watch?v=cCiXqK9c18g' and in the video he make a class that represent a ball and he used pymunk to make a body and added it to the space and after that he created a method inside the ball class that…
2
votes
1 answer

Python code problem displaying a polygon in PyGame using a polygon modeled in PyMunk

I am trying to model physics in pymunk and display using pygame and it works well so far with circles and a simple line. The problem I have is that I am trying to model a rectangle. In pymunk that is a ploygon and I can create it using:- def…
Iain
  • 51
  • 1
  • 6
2
votes
1 answer

Mac M1 "No module named 'pymunkoptions' "

When I try to run an arcade file on my MacBook M1 it returns the error ModuleNotFoundError: No module named 'pymunkoptions'. In debugging I noticed that it got called as soon as the code referenced arcade, and that it has to do with the arm64…
2
votes
1 answer

Pymunk bodies colliding without touching each other

Why do bodies in pymunk keep colliding without actually touching each other even after the position and body shape is correctly set? You will see from my code below that the bird keeps colliding with the ball without actually touching the…
2
votes
2 answers

How to make a L-shaped body in pymunk?

I am new to pymunk and I want to make a L-shaped body like this. I read that it is possible to have two shapes attached to same body but the best I got is this. The code I used is this: import pymunk import pygame import…
2
votes
1 answer

How do I make pymunk objects collect towards a central point using gravity?

In Pymunk, you can set gravity to make it so objects will go left or right (x) and up or down. (y) I would like to change the gravity so objects collect in the centre, sort of like a centre of mass. Is there any possible way to do this?
daysant
  • 21
  • 3
2
votes
1 answer

When i call SPACE.step(1/FPS) all my bodies position Vec2D becomes NaN

I'm working on a simples 2D top-down game and I started using Pymunk to handle physics. I've created a GameObject class that contains basically a pymunk.Body, a pymunk.Shape and a pygame.Surface. Here is the code part were everything goes…
1
2
3
11 12