About the SimpleMotor and joints in a platformer...

Official forum for the Chipmunk2D Physics Library.
Post Reply
EKr
Posts: 4
Joined: Fri May 21, 2010 8:20 am
Contact:

About the SimpleMotor and joints in a platformer...

Post by EKr »

Hi, all!

I'm leading a 2d-platformer game project, in which I decided to let Chipmunk do the physics. I've been very impressed by its performance indeed! However, I've come up with many questions, since I just cannot figure out everything by playing with the library and reading through the documentation. So, I decided to sign up here.

At the moment I'm impementing the characters and their movement. Since surface velocity isn't working very well, I've been reading through the forum and decided to give the wheel-motor-contraption a try. Now I have a wheel below the joint. This is my configuration:

Main Object (body and shape) <- body has inertia set to infinity so it won't rotate (or "fall over")
The Wheel (body and shape) <- body has its inertia calculated for this circle
PinJoint <- connects the bodies of these two objects above... the wheel's anchor point is at (0,0) <- origo
SimpleMotor <- sets the angular velocity between the bodies of these two objects

My perception by reading the documentation is that PinJoint locks two bodies together at a given point. Contrary to this, when I run the simulation, my Main Object and The Wheel seem very loosely connected and even when the weel bumps into something it begins rotating along a totally arbitrary axis which looks very dizzy. So my question is, how do I lock these two bodies as it's done in real vehicles; so that their anchor points stay at where I've put them?

Thanks in advance,

Slembcke, you've done great job with the lib! I wish I'll master its full use some day.

EKr
[size=120][b]E.Kr.[/b][/size]
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: About the SimpleMotor and joints in a platformer...

Post by slembcke »

You should check out the pin joints in the constraint demo video. (http://code.google.com/p/chipmunk-physi ... Constraint) Pin joints connect to anchor points by a fixed length pin or rod. I'm not sure if "pin joint" is actually a real technical term. Some paper I read a few years back called it that, so I used the same name.

Anyway, what you want is a pivot joint.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
EKr
Posts: 4
Joined: Fri May 21, 2010 8:20 am
Contact:

Re: About the SimpleMotor and joints in a platformer...

Post by EKr »

Ok, thanks for that! I'll try the PivotJoint instead.

But I'm still wondering what would the same configuration as shown in the video look like if the PinJoint's distance was set to zero, as I did; would it be even close to PivotJoint... I know, one shouldn't try to make a joint to do another joint's job. ;)
[size=120][b]E.Kr.[/b][/size]
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: About the SimpleMotor and joints in a platformer...

Post by slembcke »

It seems like it should, but the pin joint only works in one direction at a time (the direction of the pin). A pivot joint works in all directions at once, so it's more stable than a very short pin which might change the direction it needs correction in every frame or even multiple times in the same frame.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests