简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM