bysreg
bysreg

Reputation: 803

Friction between moving static body and dynamic body

So, I'm developing some kind of running game in 2d (automatic side scrolling). I created the platform consisting with tiles, and ramps with static bodies and every update, i move every tile to it's new x position with setPosition.

At one time, i want to create box body in the sky so that it will drop to the platform, but the friction between the item and the moving body isn't working. in flat ground, the box didnt go to the left of the screen(the ground moves from right to left).

i read from the box2d manual that

Friction will not work correctly if you move a static body

so is there any better approach or solution?

Upvotes: 0

Views: 846

Answers (1)

bysreg
bysreg

Reputation: 803

so, i've found it out my self. it turns out moving body with setposition doesnt cause any friction. You can imagine it like suddenly transporting it. So the solution is to change static body to kinematic and use setlinearvelocity to move it

Upvotes: 1

Related Questions