Objects sliding horizontally (no friction)

Discuss any Chipmunk bugs here.
Post Reply
ehudros
Posts: 17
Joined: Fri Oct 12, 2007 8:59 pm
Contact:

Objects sliding horizontally (no friction)

Post by ehudros »

Hi :)
I have a basic "floor" shape and body as seen in the moon buggy tutorial which is totally horizontal and flat.
Balls are bouncing from the top of the screen towards the floor with no elasticity and fricition value of 5.0.
instead of losing speed upon impact and stopping, the slide as if on an ice plain towards the left part of the screen and then hit another wall and stop. Im only guessing this has something to do with the tangent of the floor being 0 cand thus causing all sorts of pain but i think i might just be missing something obvious here.
has anyone come across such an issue? Other than that its a great library, thanks a lot!

Ehud
Michael Buckley
Posts: 46
Joined: Tue Aug 21, 2007 10:30 am
Contact:

Re: Objects sliding horizontally (no friction)

Post by Michael Buckley »

Dud you assign a friction value to the floor as well? As it says in the chipmunk documentation, the friction coefficient between two objects is calculated by multiplying the friction of the two objects together. Therefore, if the floor has a friction of 0.0f (which is the default), then it you will have a friction coefficient of 5.0f * 0.0f = 0.0f.
ehudros
Posts: 17
Joined: Fri Oct 12, 2007 8:59 pm
Contact:

Re: Objects sliding horizontally (no friction)

Post by ehudros »

thanks for your quick reply :)
At first I thought you're right (it does make a lot of sense) but then i checked my code and was disappointed to see that I actually didnt forget to assign the floor with a friction value:


Code: Select all

cpBody* staticBody = cpBodyNew(INFINITY, INFINITY);
  cpShape *seg = cpSegmentShapeNew(staticBody, cpv(GameData->GetLeftBorder(), 0.0), 
                                                                          cpv(GameData->GetLeftBorder(), GameData->GetHeight()), 0.0f);
// friction for the floor
        	seg->u = 1.0;	
	cpSpaceAddStaticShape(space, seg);
and the object is also assigned with a value of 1...

am i missing something here?
ehudros
Posts: 17
Joined: Fri Oct 12, 2007 8:59 pm
Contact:

Re: Objects sliding horizontally (no friction)

Post by ehudros »

hmm... nobody? :(
some more research shows that the circles are actually rolling on the floor (I rendered them with the rotation values this time), and it is quite strange as I would expect them to stop after a short while if the friction value is high.
does chipmunk rely somehow on the coordinate system to be openGL based (meaning 0,0 is the center of the screen or something like that)?
Im using HGE as my game engine and everything else seems to be working fine, so i doubt i has something to do that.

the code is too complex to upload as it is, but if neccessary i can build a small demo.
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Objects sliding horizontally (no friction)

Post by maximile »

Is it possible that this is expected behaviour? Because no surfaces are sliding against each other?

The way I imagine it, setting high friction values when it's a circle would just make the circle less likely to spin "against" something, rather than controlling its tendency to roll. Perhaps you'd have to change that some other way.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Objects sliding horizontally (no friction)

Post by slembcke »

Ah yes. I have not implemented rolling friction. The friction values just prevent the surfaces from slipping past each other. Rolling friction is caused by the objects deforming at the collision points and loosing energy that way. Not the same as normal friction.

Sorry about the late reply.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
ehudros
Posts: 17
Joined: Fri Oct 12, 2007 8:59 pm
Contact:

Re: Objects sliding horizontally (no friction)

Post by ehudros »

thanks Scott for your answer and the great engine :)
Is there a way to overcome the issue somehow? fake it?
do you have plans to get rolling friction in the engine anytime soon?

Thanks!
Michael Buckley
Posts: 46
Joined: Tue Aug 21, 2007 10:30 am
Contact:

Re: Objects sliding horizontally (no friction)

Post by Michael Buckley »

Well, you could set the inertial mass of the body to be INFINITY. It wouldn't roll anymore, but it should be affected by friction.
ehudros
Posts: 17
Joined: Fri Oct 12, 2007 8:59 pm
Contact:

Re: Objects sliding horizontally (no friction)

Post by ehudros »

I was able to fake rolling friction by multiplying the velocity of each ball by 0.95 every timestep.
It looks alright, and the effect is the same...

PS - I am also checking out box2d and I was wondering if someone could give me a rundown on the differences between the 2 engines?
It seems like the features are more or less the same.
thanks! :)
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Objects sliding horizontally (no friction)

Post by slembcke »

ehudros wrote:I was able to fake rolling friction by multiplying the velocity of each ball by 0.95 every timestep.
It looks alright, and the effect is the same...
I did that for a proof of concept side scrolling mingolf game as well. It works OK. It's exponential instead of linear. Not particularly noticeable for slow rotating objects, but for fast rotating ones it is.
ehudros wrote:PS - I am also checking out box2d and I was wondering if someone could give me a rundown on the differences between the 2 engines?
It seems like the features are more or less the same.
thanks! :)
No idea really. I'm using Erin's impulse solver, otherwise everything else was written by me. Haven't had the time to look into it. I'd be interested to hear too. Scope out the competition in the free 2D physics scene. Must destroy!
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: No registered users and 9 guests