Moving an Inifite mass object? [solved]

Official forum for the Chipmunk2D Physics Library.
Post Reply
lucas
Posts: 54
Joined: Wed Sep 26, 2007 2:34 am
Contact:

Moving an Inifite mass object? [solved]

Post by lucas »

Hi,
I'm trying to create a game where objects fall onto a mouse controlled paddle, and the aim is to catch them all without dropping any. I gave the paddle (which I don't want to move) infinate mass and moment of inertia, and to move it I set the position to the mouse's x value every step. However, like the documentation says, it plays with the collisions a little bit. When I move the paddle to the side into an object, instead of pushing the object the object just goes inside the paddle and falls off the screen.
Is this because I'm setting the position every step, and if it is, how can if move the paddle?

Thanks!
Tangame - a tangram puzzle game with physics.
http://code.google.com/p/tangame/
X-0ut
Posts: 28
Joined: Tue Oct 02, 2007 5:02 am
Contact:

Re: Moving an Inifite mass object? [solved]

Post by X-0ut »

If I where to do this, I'd not adjust the position directly, but adjust the velocity instead.
Then if I read right, you want the shapes that land on the pad to "stick", I'd remove the shapes cpbody and add it to the pad's cpbody instead.
I could be wrong, but thats how I would do it.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Moving an Inifite mass object? [solved]

Post by slembcke »

The problem is that you aren't giving the paddle any velocity. It's only moving around because you are setting it's position every frame. When the ball hits it, the paddle will always have a velocity of zero.

Keep in mind that mouse events are really coarse and you can't rely on them to produce smooth movements. You'll have to smooth them out if you want to get a good consistent reaction out of them.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
lucas
Posts: 54
Joined: Wed Sep 26, 2007 2:34 am
Contact:

Re: Moving an Inifite mass object? [solved]

Post by lucas »

Sorry, I thought I edited my post to say I figured out the problem. I made it change the velocity and it works fine.

Thanks!
Tangame - a tangram puzzle game with physics.
http://code.google.com/p/tangame/
Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests