Friction not applied?

For all the physics guru…

I have a static floor. I also have a dynamic box.

Both have friction to them.

Now, if I move the static floor to the left by 200, I would expect the box to also move to the left because of the friction. But in my test, only the floor move to the left? What am I missing!

I’ve try increasing friction, but still, the box doesn’t move, even if it sits on the floor…

local physics = require("physics") physics:start() physics.setGravity(0,20) physics.setDrawMode("hybrid") --- The floor floor1 = display.newRect(0, display.contentHeight - 20,display.contentWidth, 20) floor1.anchorX = 0 floor1.anchorY = 0 floor1:setFillColor( 1,1,1 ) physics.addBody(floor1, "static", { friction=1, bounce=0.01, density=2.0 }) local box = display.newRect(500, 100, 100, 100) physics.addBody( box, "dynamic", { friction=1, bounce=0.01, density=2.0} ) box.rotation = 1 box:addEventListener( "tap", function() transition.to(floor1, {x = floor1.x -200, time=1000}) end )

It is not a good idea to use the transition library on physics bodys. You should try applyForce, linear Impuse, or something that effects physics bodys

Check out this tutorial for help
https://coronalabs.com/blog/2015/10/05/tutorial-physics-based-animation/

  1. Use physics for the movement.

  2. Static objects can’t move via physics.

  3. Use Kinematic and setVelocity() (for a period of time) and see what you get.

  4. scottrules44 is exactly right.  The physics system has no idea that transitions are moving the object (while it will detect the change, it completely ignores what happened between the two positions)  You simply can’t combine the two systems like this and get the real-world (simulated) result you expect.  

Ok, but my floor is static. What do you suggest? Kinematic?

Kinematic objects are not affect by gravity. The blog post above shows how to move a platform back and forth with physics. But to answer your question I think roaming gamer want you to set you floor to kinematic.

Make sense since Static object should’t be moving… Kinematic is perfect for a floor then. Thanks a lot for the pointer!

It is not a good idea to use the transition library on physics bodys. You should try applyForce, linear Impuse, or something that effects physics bodys

Check out this tutorial for help
https://coronalabs.com/blog/2015/10/05/tutorial-physics-based-animation/

  1. Use physics for the movement.

  2. Static objects can’t move via physics.

  3. Use Kinematic and setVelocity() (for a period of time) and see what you get.

  4. scottrules44 is exactly right.  The physics system has no idea that transitions are moving the object (while it will detect the change, it completely ignores what happened between the two positions)  You simply can’t combine the two systems like this and get the real-world (simulated) result you expect.  

Ok, but my floor is static. What do you suggest? Kinematic?

Kinematic objects are not affect by gravity. The blog post above shows how to move a platform back and forth with physics. But to answer your question I think roaming gamer want you to set you floor to kinematic.

Make sense since Static object should’t be moving… Kinematic is perfect for a floor then. Thanks a lot for the pointer!